Categories/Fields Searched in Results
I'm needing to conditionally show what was searched above results. Easy enough for keywords based on your example, but I'm having trouble getting my head around how to do it for a separate search I have with a mix of cats/channel fields. A search might look like this:
/resources/results?category=82|90&search:resource_counties=Adams
Here's the code I'm trying to get the output into:
{exp:low_search:results query="{segment_4}" require_all="category" channel="resources"}
{if count == 1}
<!-- If a Keyword Search -->
{if "{low_search_keywords}"!=""}Searched for keyword(s): {low_search_keywords}
{/if}
<!-- If a Category -->
Filtered by categories: CATS HERE
<!-- If a Channel Field is selected -->
Counties selected: COUNTIES HERE
<!-- Results Count -->
Search results: {absolute_results}
{/if}
.... actual results code
{/exp:low_search:results}
Saw this post but different enough that all I garnered is that maybe I should be using filters? Are there tags as simple as
{low_search_keywords}
for cats or channel fields? Just can't get syntax/approach right.
Replies
Low 30 Nov 2018 14:20
The thing to remember is that a {low_search_PARAM} variable contains whatever that parameter value is. And as you can see in your URL:
{low_search_category} would be
82|90
{low_search_search:resource_counties} would be
Adams
In order to filter by category, EE and LV need Category IDs, so that's what's returned for that variable. If you want to display the associated category names, you need a channel:categories tag. The good thing is that that tag accepts a show= parameter to limit the categories returned. So, we can limit the categories here to those that were given in LS:
Use the same approach for other parameters that return IDs.
If the field returns a pipe-separated list of strings that you want to display, you could use Low List to loop through those values.