Custom field searching for 'not equal to'
Hi Low,
I'm being asked if it's possible to have the option of running 'not equal to' searches in Low Search.
So by default, the custom field searches will search for values that equal what's selected in the field. Is it possible to say, tick a checkbox with certain values/parameters, in order to search for values that don't equal what is selected in this field instead? So it would look something like this (I've completely made up the checkbox code for this of course):
{exp:low_search:form collection="ls_event_search" search_mode="all" result_page="/searches/entry-full-results" secure="no" query="{segment_3}"}
<p><label>Event category</label></p>
<p><select name="search:cf_event_entry_category[]" multiple="multiple">
{exp:low_options:cf_event_entry_category}
{options}
<option value="{option:value}">{option:label}</option>
{/options}
{/exp:low_options:cf_event_entry_category}
</select></p>
<label><input type="checkbox" name="search:cf_event_entry_category[]" value="not" /> Not equal to Event category</label>
<p><input type="submit" value="Search" /></p>
{/exp:low_search:form}
I tried the following but it only worked when I selected one value in the 'Not equal to' multi-select. Is is possible run a 'not' search for multiple values in a multi-select at all?
{exp:low_search:form collection="ls_event_search" search_mode="all" result_page="/searches/entry-full-results" secure="no" query="{segment_3}"}
<p><label>Event category</label></p>
<p><select name="search:cf_event_entry_category[]" multiple="multiple">
{exp:low_options:cf_event_entry_category}
{options}
<option value="{option:value}">{option:label}</option>
{/options}
{/exp:low_options:cf_event_entry_category}
</select></p>
<p><label>Not Equal to Event category</label></p>
<p><select name="search:cf_event_entry_category[]" multiple="multiple">
{exp:low_options:cf_event_entry_category}
{options}
<option value="not {option:value}">{option:label}</option>
{/options}
{/exp:low_options:cf_event_entry_category}
</select></p>
<p><input type="submit" value="Search" /></p>
{/exp:low_search:form}
Thanks,
Stephen
Replies
Low 17 Jun 2013 06:48
Yes, you can use the exclude parameter. So, in your case:
Or use a checkbox:
Stephen 17 Jun 2013 10:48
Thanks Low. Not sure how I missed that one! Think I was looking for 'not' to match the channel entries parameter.
Thanks,
Stephen