Override saved_venues_dropdown()

Home Forums Calendar Products Community Events Override saved_venues_dropdown()

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #960360
    gonzalosanza
    Participant

    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.

    #960465
    Barry
    Member

    Hi 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?

    #960479
    gonzalosanza
    Participant

    Hi Barry, and thanks!
    I have tried with this code

    add_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!

    #960520
    Barry
    Member

    Hi 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?

    #960556
    gonzalosanza
    Participant

    Many 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>

    #960591
    Barry
    Member

    Hi 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 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Override saved_venues_dropdown()’ is closed to new replies.