• Hi there again,
    I need to alter my event search query so the user can select Multiple Categories when searching.
    I have put Checkboxes in the search form for this purpose which would be passing their selections with the form output thusly
    (sorry for the formatting but it mucks up when pasted here)
    ———————————-
    <?php if( !empty($search_categories) || (get_option(‘dbem_search_form_categories’) && empty($search_categories)) ): ?>
    <!– START multi select Category Search –>
    <input name=”CatAll” type=”checkbox” value=”ALL”>All

    <?php foreach(EM_Categories::get(array(‘orderby’=>’category_name’)) as $EM_Category): ?>
    <input name=”category[]” type=”checkbox” class=”em-events-search-category” value=”<?php echo $EM_Category->id; ?>” <?php echo (!empty($_REQUEST[‘category’]) && $_REQUEST[‘category’] == $EM_Category->id) ? ‘selected=”selected”‘:”; ?>><?php echo $EM_Category->name; ?>
    <?php endforeach; ?>
    <!– END Category Search –>
    <?php endif; ?>
    ———————————-
    I have used the format input name=”category[]” so that the GET result will create an array of selected values automatically

    The input
    <input name=”CatAll” type=”checkbox” value=”ALL”>All
    can be used to determine whether to use any of the mutliselect values or not.

    ………………..

    Now I am trying to alter the SQL query to make use of this.
    But can’t find where to go about that.
    Looked in Tutorials at
    https://wp-events-plugin.com/tutorials/create-your-own-event-scope/
    and put a bit of code like that in my Theme’s functions.php
    From that I can see the SQL array variables created including

    [category] => wp_em_events.post_id IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id=7 )

    But then I get lost not knowing about term_taxonomy_id ??
    It would seem that wp_term_relationships is a DB Table relating each event to the categories it belongs to ? That’s good.
    And term_taxonomy_id would be the one I selected in the normal form’s selection dropdown.
    But when I think about how to use this process to alter the query in the way I need to I realise that I will need access to the array of Categories which will be being returned in the GET from the form and no idea how to get hold of that.

    So what I need I think is where the SQL is actually created from the GET results
    OR
    Maybe someone to code this change for a fee ?? ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • hey wattagan! i would also need to select multiple categories in the search form. did you ever found a solution for that?

    Thread Starter wattagan

    (@wattagan)

    Hi Kmra,
    Have a look at https://www.thegasketguide.com to see how it looks.
    Just changed the List to a group of check boxes.
    But even easier it works if you just add the word Multiple to the dropdown box definition.
    But user then has to be prompted to hold down Ctrl key when selecting multiples.

    Thanks! Looks good!
    This seems to be exactly the thing i am looking for. I changed the events-search.php to display checkboxes – and i also tried to add the word multiple to the select box, however, it seems that the search function only searches for just one category (because i haven′t changed the SQL-Query yet to make use of the category[]-array – as you described in your first post).
    My problem: i just do not know where the sql-query is located or what and where i exactly have to add some code to get the multiple select running.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Manager] altering search query’ is closed to new replies.