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

Support archive

How do I filter by collection?

Niall O'Brien 18 Jul 2014 12:01 question, complete

Hi, right now I'm using Stash and Low_Search to achieve the search results formatting I need.

I Stash the keyword results using {exp:stash:set_list} and use get_list with match="#regex#" to get and display "grouped" results.

Where I'm struggling at the minute is filtering this keyword list to only return a result for the selected collection.

I've tried something like
{!-- Media Type (photos, videos etc.) --}

{collections}
{collection_label}
{/collections}

{!-- Stash our search results into one big list and stash whatever variables we'll need in our template --}
{exp:stash:set_list name="all_results" parse_tags="yes"}
{exp:low_search:results query="{segment_3}" collection="{low_search_media_type}"}
{stash:result_low_search_media_type}{low_search_media_type}{/stash:result_low_search_media_type}
...
...
...
{/exp:low_search:results}
{/exp:stash:set_list}

I can output {result_low_search_media_type} in my template no problem, but I'm not sure how to approach filtering my search term result list for a specific collection.
Any help's appreciated.

Thanks in advance.

Replies

  1. Low 21 Jul 2014 07:45

    I haven't really used Stash all that much, so I cannot really comment on that. If you're looking to filter a Stash list by collection, you'd probably need to set the given collection as a variable within that list (which you can do with the {low_search_collection_name} vars per search result), and then filter by that.

    But that is something you'd probably better ask Mark Croxton.

  2. Niall O'Brien 21 Jul 2014 10:24

    Hi, thanks for your reply. Yeah, I had to create a Stash list of the keyword search results, get the low_search_collection_name within that, assign it to a Stash var and use that to limit a nested Stash list. Not ideal but it works. Thanks.