All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Low Search - Refine results by adding / removing category filters

alan poon 7 Nov 2012 05:36 question, complete

Hi,

I just purchased Low Search, and I'm interested in building search / filter capabilities similar to devot-ee.com and warnerbros.com.au, where the user can search or filter for a category, and further refine their results by adding/removing category filters. (I'm very new to EE so please bear with me)

Reading the docs, it seems that you would use the "query" tag to input the previous search results, and then incorporate the additional category. I'm guessing you would just get this from {segment_3}... Is that correct?

If so - that seems to work for adding category filters, but how do you "remove" one of the category filters that was selected?

Also, on both devot-ee.com and warnerbros.com.au it seems that the search results are refreshed through a hyperlink, rather than a search button. I read on EE forums that with the native capability, it's not straightforward to submit the search with a hyperlink. Is there an easier way to do this with Low Search?

Any help would be greatly appreciated... Thanks in advance!
Alan

Replies

  1. Low 7 Nov 2012 08:40

    Hi Alan,

    Take a look at the advanced example, and particularly the Categories bit. There you can see a multiple select field being generated. You could easily swap this with checkboxes by replacing that bit with something like this:

    {exp:channel:categories} 
    <input type="checbox" name="category[]" value="{category_id}"
    {if category_id IN ({low_search_category})}checked="checked"{/if} />
    {category_name}
    {/exp:channel:categories}


    The {if ... IN ()} conditional is only available in the low_search:form and low_search:results tags, and will make it easy to remember the selected items.

    Ad for submitting with a hyperlink -- that's something on the front end you'll have to manage yourself. I reckon some simple JavaScript code can take care of that for you.

  2. alan poon 7 Nov 2012 15:22

    Thanks for the quick response! Will try that out today and report back.

    Cheers,
    Alan

  3. alan poon 8 Nov 2012 02:45

    Got a bit stuck :(

    So, I'm able to implement the checkbox and add multiple categories to category[], the search results look great.

    But - on the results page:

    {exp:low_search:results} -> {low_search_category} has the selected categories
    {exp:low_search:form} -> {low_search_category} is empty

    And the checkboxes are part of the form, so I'm not able to use the IF statement to identify which ones are already checked...

    Am I using this incorrectly?

    Thanks in advance,
    Alan

  4. alan poon 8 Nov 2012 04:53

    Never mind, got it - forgot query="{segment_3}"... It's working great!

    Amazing add-in, thanks for the help!