Can't seem to get the category filter to work.
Hi,
I set up a simple form using a keyword, category, and date filter. Keyword is set to required and works well in combination with the date filter, but not the category filter. When searching for a known keyword in combination with a category that has no entries I get all the results from the keyword instead of "no entries found".
I feel like I'm missing something simple and would appreciate any insight into what the problem may be. Thank you.
The following is the code for my search form:
{exp:low_search:form result_page="business_groups_001/eppr_search_results" required="keywords"}
<fieldset>
<label for="keywords">Keywords</label>
<input type="search" name="keywords" id="keywords" />*Required
<br><br>
<label for="category[]">Categories</label>
<select name="category[]">
<option value="">Select</option>
{exp:channel:categories category_group="9" style="linear"}
<option value="{category_id}"{if low_search_category ~ '/\b'.category_id.'\b/'} selected{/if}>
{category_name}
</option>
{/exp:channel:categories}
</select>
<br><br>
<label for="range-from:entry_date">Date Range</label>
<input type="date" name="range-from:entry_date"> -
<input type="date" name="range-to:entry_date">
<br><br>
<button type="submit">Search</button>
</fieldset>
{/exp:low_search:form}
The results page:
{exp:low_search:results query="{segment_3}" require_all="category" limit="1000" channel="publications" category="4" dynamic="no"}
{if count == 1}<ol>{/if}
<li><a href="{page_url}">{title}</a><br>
{entry_date format="%F %j, %Y"}<br>
{pub_blurb}</li>
{if count == total_results}</ol>{/if}
{if no_results}No search results{/if}
{/exp:low_search:results}
Replies
Low 29 Dec 2016 09:18
You've got the category parameter hard-coded on your Results tag, which will always override the selection made in the form. Try removing the category param on the Results tag.
Chris 4 Jan 2017 16:26
Thank you! I got it working.
To replicate the category parameter function I added a hidden field in the search tags.