Home › Forums › Calendar Products › Filter Bar › Custom filterbar for filtering countries
- This topic has 4 replies, 2 voices, and was last updated 9 years, 1 month ago by Barry.
-
AuthorPosts
-
January 4, 2015 at 4:05 am #928423OliverParticipant
Hi Barry, hi Brook,
I want to create a custom filter for filtering the events of specific countries.
As described in this posts I created a new filter file and added a hook in the functions.php:
https://theeventscalendar.com/support/forums/topic/adding-custom-filter-to-filter-bar/
https://theeventscalendar.com/support/forums/topic/adding-custom-filter-to-filter-bar-2/functions.php:
add_filter( 'tribe_events_all_filters_array', 'custom_add_filter_callback' ); function custom_add_filter_callback( $filters ) { $filters['TribeEventsFilter_Country'] = array( 'name' => 'Country', 'type' => 'select', 'admin_form' => 'Titel: <input name="tribe_filter_options[country][title]" value="Land" type="text">', ); return $filters; }
Question 1:
What are the available options for type? (radio, checkbox, select?)lib/filters/TribeEventsFilter_Country.php (currently it’s only a slightly modified copy of http://pastebin.com/30mZSeKk)
https://www.dropbox.com/s/9juqgeb9yyaf43q/TribeEventsFilter_Country.php?dl=0The filter appears in the backend successfully:
https://www.dropbox.com/s/1ctz3w2nziepjq5/Screenshot%202015-01-04%2012.55.28.png?dl=0Question 2
In the frontend the filter doesn’t appear. Can you give a hint where the problem resides?Best regards,
OliverJanuary 5, 2015 at 9:58 am #928854BarryMemberHi Oliver π
Question 1:
What are the available options for type? (radio, checkbox, select?)Right now the available types are:
- select
- autocomplete
- checkbox
- radio
- range
- multi-select
TribeEventsFilter::displayFilter() (lib/tribe-filter.class.php lines 161-411 in the current release) contains a large select statement and, essentially, each case represents one of the above types – so if we add additional types in the future as we recently did (ie, “autocomplete”) you will probably find them in there.
Question 2
In the frontend the filter doesnβt appear. Can you give a hint where the problem resides?It’s basically looking good but I think you just need to tie a few things up in order to give the Filter Bar plugin enough information to understand what you’ve put in place.
Note that your class (in this file) is named TribeEventsFilter_Country but after the class definition you are actually instantiating a class of a different name:
new TribeEventsFilter_Custom('Taxonomy', 'taxonomy_filter');
This ought to be new TribeEventsFilter_Country(/*…*/) – and the first parameter ought to be
‘Country’, too, so that it matches the information you provide in your tribe_events_all_filters_array callback.Last but not least, I’m not sure when that file (the one containing your custom country filter class) is loaded but it would be best to do so from the tribe_events_filters_create_filters action.
I hope that helps – and good luck π
January 21, 2015 at 8:27 am #935722OliverParticipantThanks Barry for the info! Due to holiday season I didn’t had time to have a look at it.
I will try to check it out the next 1-2 weeks.Please leave the thread open!
Cheers,
OliverJanuary 21, 2015 at 8:43 am #935734BarryMemberI’ll try and do that π
(If it is inadvertently closed after a period of inactivity, though, please just create a new topic and link to this one to provide some context – thanks!)
February 9, 2015 at 6:21 am #940885BarryMemberHi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!
-
AuthorPosts
- The topic ‘Custom filterbar for filtering countries’ is closed to new replies.