Home › Forums › Calendar Products › Filter Bar › Is there a template include I can use to make the filter bar appear elsewhere?
- This topic has 9 replies, 2 voices, and was last updated 9 years, 9 months ago by Barry.
-
AuthorPosts
-
July 25, 2014 at 4:58 am #505001Timothy LindsayParticipant
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.
July 25, 2014 at 1:44 pm #507978BarryMemberHi!
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):
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 ๐
July 28, 2014 at 2:45 am #523769Timothy LindsayParticipantHi Barry, that’s some great info to get started on – thank you!
July 28, 2014 at 12:37 pm #527368BarryMemberMy pleasure, I hope you figure something out here ๐
July 30, 2014 at 8:36 am #540018Timothy LindsayParticipantHi 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?
July 30, 2014 at 8:52 am #540117Timothy LindsayParticipantWell 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…
July 30, 2014 at 9:09 am #540213Timothy LindsayParticipantAfter 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!
July 30, 2014 at 10:10 am #540672BarryMemberYou 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 );
July 31, 2014 at 4:42 am #547699Timothy LindsayParticipantPerfect! Thanks again ๐
July 31, 2014 at 1:48 pm #550331BarryMemberNo 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!
-
AuthorPosts
- The topic ‘Is there a template include I can use to make the filter bar appear elsewhere?’ is closed to new replies.