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

Support archive

How can I apply a category filter to all results by default and allow further filtering

foamcow 11 Dec 2014 08:03 question, complete

I am using Low Search filters to allow customers to refine list of products shown to them. It works great but now I find that I need to apply a particular filter to all 'searches' performed on a particular page.

Let's say we have products of type A,B, and C. Each of these is a category (product-type). There are further categories which can also apply to all products.

I need to create a page for each product type so it will only ever show products of that type and allow further filtering using the other categories.

I tried adding a category="" parameter to the low_search_results tag which works fine when the results have no other filters applied but seems to prevent further filtering from happening.

The results tag looks like (with some ordering params removed):

{exp:low_search:results query="{segment_3}" channel="products" limit="18" cache="yes" refresh="120" category="52" require_all="category"}

In this particular case it will show results from category 52 but if I try to apply any filters it still shows all results from category 52.

Is there a way to achieve this or am I going to need to rethink my strategy here?

Replies

  1. foamcow 11 Dec 2014 08:49

    With a second look I managed to sort it out.

    I set the results tag thus to force the display of all results in the category if there was no query;

    {exp:low_search:results query="{segment_3}" channel="products" limit="18" cache="yes" refresh="120" {if segment_3==''}category="52"{/if} require_all="category"}

    Then I changed my filters to combine the category id with the filter.

    <a href="{low_search:url toggle:category='{category_id}&52'}">{category_name}</a>

  2. Low 11 Dec 2014 08:55

    For default values, you can also use the default:parameter syntax on the Results tag.

  3. foamcow 11 Dec 2014 10:09

    I tried using the default:parameter parameter but couldn't get it to work.

    Would it be used like; default:category="52" ?

  4. Low 11 Dec 2014 10:10

    Yes, that would be the syntax. If that parameter isn't set in the query, it will fall back to that value.

  5. foamcow 11 Dec 2014 11:39

    I'll give that a go as it's a lot neater. Thanks!