Home › Forums › Calendar Products › Community Events › Override saved_venues_dropdown()
- This topic has 5 replies, 2 voices, and was last updated 9 years ago by Barry.
-
AuthorPosts
-
May 4, 2015 at 4:15 pm #960360gonzalosanzaParticipant
I need to change the behaviour of saved_venues_dropdown() which is in the-events-calendar/lib/the-events-calendar.class.php
I know that I can override views by placing a new version in my theme’s tribe-events folder, but can I do this with the aforementioned file? If so, I must not have the folder structure right. Any hook or similar?
(the reason because i want to override it, is because I have created a custom field for venues and organizers, which allows admins, to decide if those venues or organizers are displayed on dropdowns, that custom field is working, but now I need to modify saved_venues_dropdown and saved_organizers_dropdown to make this feature work properly)
Any advice?
Thanks.
Gonzalo.May 5, 2015 at 6:42 am #960465BarryMemberHi Gonzalo,
Overridding the template (modules/venue.php in this case) is still a good way to go since if you write a replacement function you can drop it in there, replacing the call to tribe_community_events_venue_select_menu().
Alternatively, you could unhook TribeEvents::displayEventVenueDropdown() — currently it runs when the tribe_venue_table_top action fires — and hook up your alternative function.
It is a slightly more advanced customization and if you have any doubts I’d recommend following the first strategy and overriding the modules/venue.php template.
Does that help?
May 5, 2015 at 6:57 am #960479gonzalosanzaParticipantHi Barry, and thanks!
I have tried with this codeadd_action( ‘wp_loaded’, ‘replace_displayEventVenueDropdown’ );
function replace_displayEventVenueDropdown() {
if ( is_admin() ) return;
$events = TribeEvents::instance();
remove_action( ‘tribe_venue_table_top’, array( $events, ‘displayEventVenueDropdown’ ) );
add_action( ‘tribe_venue_table_top’, array( $events,’displayEventVenueDropdown_custom’) );
}function displayEventVenueDropdown_custom( $postId ) { …my custom code… }
But Im getting this error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘TribeEvents’ does not have a method ‘displayEventVenueDropdown_custom’ in /home/mydomain/public_html/wp-includes/plugin.php on line 496
I tried smalls modifications on this, but nothing…
Any help? Thanks anyway!
May 5, 2015 at 7:35 am #960520BarryMemberHi Gonzalo!
add_action( 'tribe_venue_table_top', array( $events, 'displayEventVenueDropdown_custom' ) );
The above is telling PHP to look in the wrong place – your custom replacement is not a part of the main event class, it’s a standalone function 🙂
Try changing that to just:
add_action( 'tribe_venue_table_top', 'displayEventVenueDropdown_custom' );
Does that help?
May 5, 2015 at 8:51 am #960556gonzalosanzaParticipantMany thanks barry, but still not working, now im getting this error:
Fatal error: Using $this when not in object context in /home/segoviaencendida/public_html/wp-content/themes/eventica-wp-child/functions.php on line 461
line 461 contains:
<td style=”width:170px”><?php printf( __(‘Use Saved %s:’, ‘tribe-events-calendar’), $this->singular_venue_label ); ?></td>and 462 contains:
<td><?php $this->saved_venues_dropdown_custom( $VenueID ); ?></td>May 5, 2015 at 9:59 am #960591BarryMemberHi Gonzalo,
If you define a standalone function – ie, it doesn’t belong to a class and will never exist within an instantiated object – then you cannot use the keyword $this.
Instead, if you need to refer to members of the main TribeEvents object from your function, please use TribeEvents::instance() in place of $this.
I hope that helps – however because we’re now very much in custom development territory we’ll be unable to help further and so I am now going to close this topic.
Good luck, though, it definitely looks like you are quickly closing in on a nice solution 🙂
-
AuthorPosts
- The topic ‘Override saved_venues_dropdown()’ is closed to new replies.