Custom filterbar for filtering countries

Home Forums Calendar Products Filter Bar Custom filterbar for filtering countries

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #928423
    Oliver
    Participant

    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=0

    The filter appears in the backend successfully:
    https://www.dropbox.com/s/1ctz3w2nziepjq5/Screenshot%202015-01-04%2012.55.28.png?dl=0

    Question 2
    In the frontend the filter doesn’t appear. Can you give a hint where the problem resides?

    Best regards,
    Oliver

    #928854
    Barry
    Member

    Hi 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 πŸ™‚

    #935722
    Oliver
    Participant

    Thanks 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,
    Oliver

    #935734
    Barry
    Member

    I’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!)

    #940885
    Barry
    Member

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Custom filterbar for filtering countries’ is closed to new replies.