• Resolved imemine

    (@imemine)


    Hi,

    For the /events/ page where we can search for events I would like my users to be able to search in multiple categories, how do I do that ?

    For categories: Rock, Paper and Scissor
    Right now say users can only search in rock , while I want them to be able to search in rock and paper , maybe I can have a ‘select box’ with ‘multiple’ field where they can select multiple categories pressing the ctrl button or something similar.

    Thanks

    http://wordpress.org/plugins/events-manager/

Viewing 9 replies - 16 through 24 (of 24 total)
  • You’d need to use something like this in your custom form:
    http://www.w3schools.com/tags/att_select_multiple.asp

    Thread Starter imemine

    (@imemine)

    As I mentioned earlier , that is what
    $('.em-events-search-category').attr('multiple','');
    does

    This is the code I need to modify as suggested by philipjohn

    $selected = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
    				EM_Object::ms_global_switch(); //in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
    Here is the category code that outputs a selectbox==>wp_dropdown_categories(array( 'hide_empty' => 0, 'orderby' =>'name', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'show_option_none' => get_option('dbem_search_form_categories_label'), 'class'=>'em-events-search-category'));
    				EM_Object::ms_global_switch_back(); //if switched above, switch back

    As Phil mentioned earlier, you can’t use the jQuery snippet to modify the behavior of the select – you have to actually make it a mulitselect in the template.

    Thread Starter imemine

    (@imemine)

    That is what I am asking here now .Code to output categories which allows multiple selection.
    The current code wp_dropdown_categories won’t allow multiple selection.

    You can’t use wp_dropdown_categories to do this because it’s not able to display in such a way as to allow multiple categories to be selected.

    You need to create your own dropdown menu for the multselect.

    Thread Starter imemine

    (@imemine)

    You can’t use wp_dropdown_categories to do this because it’s not able to display in such a way as to allow multiple categories to be selected.

    You need to create your own dropdown menu for the multselect.

    That is what I am asking, how do I do that ?

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Can’t give a step-by-step, but here’s the gist of it. You’d want to override the templates/templates/search/categories.php file as per these instructions:

    http://wp-events-plugin.com/documentation/using-template-files/
    http://www.w3schools.com/tags/att_select_multiple.asp

    I’m pretty sure that’s all you need, but it’s possible that EM doesn’t accept multiple category searches (never tested it via search form). If that’s the case, then some more coding would need to be done by you, along the lines of:

    http://wp-events-plugin.com/tutorials/adding-custom-event-search-form-fields/

    but instead convert it to a comma-delimited list of category ids

    Thread Starter imemine

    (@imemine)

    Thanks Marcus .

    Fixed it.

    Used

    $(function() {
    
    $('.em-events-search-category').attr('size','15');
    $('.em-events-search-category').attr('multiple','');
    });

    Used custom template.
    and used comma-delimited list of category ids .

    I’ll send you all a box of cookie 😀

    Thanks

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    yum!

Viewing 9 replies - 16 through 24 (of 24 total)

The topic ‘Multiple selection for categories during search’ is closed to new replies.