Is there a template include I can use to make the filter bar appear elsewhere?

Home Forums Calendar Products Filter Bar Is there a template include I can use to make the filter bar appear elsewhere?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #505001
    Timothy Lindsay
    Participant

    I have the filter bar working, but I’d like it to show in my sidebar underneath my Calendar Widget (from the Events Calendar Pro) instead of it’s default location.

    So first I’d like to hide the filter bar at it’s current location.

    Then I’d like to use a template include to add the filter bar to my sidebar template.

    What’s the recommended way to do the above?

    As a feature request, it would be great if the filter bar came as a widget that could be placed around the site as required.

    #507978
    Barry
    Member

    Hi!

    The best place to post feature requests is over on our UserVoice page (remember to check for suitable existing requests, too, which you can then support by upvoting):

    tribe.uservoice.com

    What you’re asking is a little more involved than we can help you with here in the support forum but, in essence, you would achieve this by:

    • Unhooking the Filter Bar from it’s default action of tribe_events_before_templateย (though it may be set to fire on the tribe_events_bar_after_template action)
    • Register your own widget class
    • From within your custom widget, call TribeEventsFilterBar::instance()->displaySidebar() directly

    I’d definitely recommend looking through the Filter Bar code before tackling this, particularly the TribeEventsFilterBar class (found in the-events-calendar-filterbar/lib/tribe-filter-view.class.php) to see how it pieces together.

    I hope that gives you a steer in the right direction – and good luck ๐Ÿ™‚

    #523769
    Timothy Lindsay
    Participant

    Hi Barry, that’s some great info to get started on – thank you!

    #527368
    Barry
    Member

    My pleasure, I hope you figure something out here ๐Ÿ™‚

    #540018
    Timothy Lindsay
    Participant

    Hi Barry,

    Following your hints, I’ve managed to get this working, so thanks!

    As it stands though, it means I’ve edited the core code of the Filter Bar plugin – I’ve simply commented out the lines of code that add the action. Not the most elegant solution, and also it will make future upgrades tricky. (In fact I see there’s already an upgrade out now!)

    So I’m trying to do as you’ve suggested – unhook the Filter Bar from it’s usual action – by adding code to my theme’s functions.php file. Here’s what I’m doing there:

    // remove default display of Tribe Filter Bar
    remove_action(‘tribe_events_before_template’, ‘displaySidebar’, 25);
    remove_action(‘tribe_events_bar_after_template’, ‘displaySidebar’, 25);

    …but the Filter Bar still shows in it’s usual location.

    I’ve added some temporary console logs to the code, in order to monitor the sequence of events, and it seems the Tribe add_action happens *after* my custom remove_action, overriding my attempt to remove it.

    Any more ideas on how I could unhook this action without editing the core code?

    #540117
    Timothy Lindsay
    Participant

    Well I’ve figured one thing out: I’m trying to remove the action in the wrong way. If the function being added is a class method (which, in this case, it is) then you have to remove the action in a specific way as documented here: http://codex.wordpress.org/Function_Reference/remove_action#Example

    I’ll try this first…

    #540213
    Timothy Lindsay
    Participant

    After reading up on removing actions, I’ve now also realised that I may need to hook up my own unhookings to another, later hook (if that makes any sense). Here’s what I’ve got so far:

    // remove default display of Tribe Filter Bar
    function removeTribeFilterBarDefaultDisplay() {
    error_log(‘Tribe filterbar unhook’);
    $filterClass = TribeEventsFilterView::instance();
    remove_action(‘tribe_events_before_template’, array($filterClass, ‘displaySidebar’), 25);
    remove_action(‘tribe_events_bar_after_template’, array($filterClass, ‘displaySidebar’), 25);
    }
    add_action(‘widgets_init’, ‘removeTribeFilterBarDefaultDisplay’);

    This isn’t working though, and there are now quite a few things that could be the problem. I feel like I’m really close though – I’d really appreciate any help you could give me!

    #540672
    Barry
    Member

    You may just need to tweak your action slightly – looks like you’ve basically got the right idea here.

    function removeTribeFilterBarDefaultDisplay() {
    	$filterClass = TribeEventsFilterView::instance();
    	remove_action('tribe_events_before_template', array($filterClass, 'displaySidebar'), 25);
    	remove_action('tribe_events_bar_after_template', array($filterClass, 'displaySidebar'), 25);
    }
    
    add_action( 'wp_enqueue_scripts', 'removeTribeFilterBarDefaultDisplay', 50 );
    #547699
    Timothy Lindsay
    Participant

    Perfect! Thanks again ๐Ÿ™‚

    #550331
    Barry
    Member

    No problem at all ๐Ÿ™‚

    I’ll go ahead and close this topic but if we can assist with anything else please do feel free to post new ones as needed and one of the team will be happy to help.

    Also, if you have a moment to spare, we’d love to hear your thoughts on The Events Calendar over on our review page – thanks again!

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Is there a template include I can use to make the filter bar appear elsewhere?’ is closed to new replies.