• 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 15 replies - 1 through 15 (of 24 total)
  • Thread Starter imemine

    (@imemine)

    Well it would be really helpful if someone can point me towards a direction.

    Thread Starter imemine

    (@imemine)

    Nobody? =(

    Thread Starter imemine

    (@imemine)

    Somebody? I also want to know how to not show any result if the form is not filled up. I don’t mean a jQuery popup or something, I want to show “No results found” or something similar.

    Hi,

    You’d basically need to create your own search template to do that and allow searches across multiple categories. You might want to take a look at /plugins/events-manager/templates/templates/event-search.php to see how the default search page works.

    You could then add your new search page as an upgrade safe template:
    http://wp-events-plugin.com/documentation/template-tags/

    Heyo – I’m actually working on this exact same issue. I’m in the process of figuring it out, but I’ll report back in in like a day or so. Basically where I’m attacking it from is creating new hierarchal taxonomies for my categories (which is all a category is anyways).

    Thread Starter imemine

    (@imemine)

    @caimin_nwl:
    What I did is added

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

    to the head of /plugins/events-manager/templates/templates/event-search.php but while it lets me choose multiple selections now, it doesn’t give the proper output. The actual query I presume is happening only for one of the categories. Now what do I do ?
    Plus, can you tell me how can I make the /event/ page don’t show any event if it was not searched for, maybe using something like is_search() or something similar ?

    @adhanaraj: I will be glad to hear back from you .

    Thread Starter imemine

    (@imemine)

    I think I found out how to stop /event/ page stop showing result if it is not a search request , using file \wp-content\plugins\events-manager\templates\templates\events-list.php

    I am still left with increasing the amount of categories someone can search for .

    What is it you need to do with the category list?

    Thread Starter imemine

    (@imemine)

    Right now for the events search page the users select date, name, location and category .
    Then can only select one category but what I want is to let them choose multiple categories.

    To carry out a search, a person must be able to narrow results by selecting categories of interest.
    Currently one can only select a single category, but I want it to allow multiple category selections.

    By adding

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

    in the header I achieved the layout I wanted after using the code I was able to select multiple categories but the output I am getting is based only upon one of my selections not all of them.
    Can you tell me in which file is the actual sql querie made after accepting the form paramaters , maybe I’ll be able to figure something out.

    Thanks

    Plugin Support angelo_nwl

    (@angelo_nwl)

    try @caimin suggestion – templates/search/categories.php and then modify template file at templates\templates\events-list.php

    eg. add

    $args['category'] = implode(",", $_REQUEST['category']);
    echo EM_Events::output( $args );

    Thread Starter imemine

    (@imemine)

    The /tempates/templates/events-search.php has the following code for the Category Search select box.

    <?php
    				$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
    				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
    			?>

    I only know how to dropdown category which is using wp_dropdown_categories, I don’t know how to allow multiple selection in it , so I added

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

    to the head of /tempates/templates/events-search.php.

    Now the /events/ page allow me to select multiple categories.
    This the post data
    POSTDATA=em_search=&scope%5B0%5D=2013-09-12&scope%5B1%5D=2013-09-28&category=18&category=16&category=9&category=20&state=&town=&action=search_events
    as you can see there are multiple parameters here names ‘category’ now,
    so your code:

    $args['category'] = implode(",", $_REQUEST['category']);
    echo EM_Events::output( $args );

    wouldn’t work.

    When I did var_dump($args); I got :
    ["owner"]=> bool(false) ["pagination"]=> bool(false) ["orderby"]=> string(44) "event_start_date,event_start_time,event_name" ["order"]=> string(3) "ASC" ["em_search"]=> string(0) "" ["scope"]=> string(21) "2013-09-12,2013-09-28" ["category"]=> string(2) "20"
    which means only the last category parameter is getting counted ,then I tried

    $mm = wp_parse_args( $mm, $args['category'] );
    		echo $mm;

    which didn’t gave me any output .

    So, basically the frontend is sending the parameters but the backend is not receiving it or maybe I am wrong somewhere.

    Any ideas ?

    P.S. As I am doing this on an offline version right now I am making changes directly to the plugin but when I’ll put it online I will be using update safe templates.

    Thanks

    Hiya,

    The problem is, I think, that you need to output a proper multiple-select feed on the search form. Doing it with jQuery isn’t going to suffice, you need to do it in the template so that you get one field as per Angelo’s suggestion.

    Thanks,
    Phil

    Thread Starter imemine

    (@imemine)

    Hi ,

    My comments:

    need to output a proper multiple-select feed on the search form

    The data is being sent anyways.
    POSTDATA=em_search=&scope%5B0%5D=2013-09-12&scope%5B1%5D=2013-09-28&category=18&category=16&category=9&category=20&state=&town=&action=search_events

    I think what angelo_nwl presumed was that the data was sent like
    category=18,16,9,20 but it was sent like
    category=18&category=16&category=9&category=20

    multiple-select feed on the search form

    Do you know how to make it in the template ? wp_dropdown_categories will make only simple dropdown categories.

    I think what angelo_nwl presumed was that the data was sent like
    category=18,16,9,20 but it was sent like
    category=18&category=16&category=9&category=20

    Yes but the former is what you need to have sent. The latter is invalid and simply won’t work.

    Thanks

    Thread Starter imemine

    (@imemine)

    I think what angelo_nwl presumed was that the data was sent like
    category=18,16,9,20 but it was sent like
    category=18&category=16&category=9&category=20

    Yes but the former is what you need to have sent. The latter is invalid and simply won’t work.

    Ok, Can you help me code the multiple select box without using jquery ?

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Multiple selection for categories during search’ is closed to new replies.