Low search extract
Hi Low,
I am in problem with keywords:mode="extract".
I have a dropdown data_quarter select field with these option:
- I
- II
- III
- IV
{exp:low_search:form query="{segment_2}" result_page="filter"}
Choose quarter
Quarter I
Quarter II
Quarter III
Quarter IV
{/exp:low_search:form}
Result page ok if quarter is III or IV, but:
- If search quarter = I, it will return entry with quarter = I, II and IV.
- If search quarter = II, it will return entry with quarter = II and III.
I think this problem is: I extract in I, II, III; and II extract in II and III.
Are there any search mode to return "extract" entry have quarter = I when I choose Quarter I?
Thank so much!
Replies
Low 27 Mar 2018 08:45
The parameter value for
keywords:mode
is exact, not extract.This will target the search terms given in the
keywords
parameter. However, looking at your use case, you're probably better of using the Field Search filter rather than the Keywords filter, because you're looking for a certain value in a specific field.Therefore, the settings you want to use are
name="search:field_name"
on the select field (where field_name is the actual name of the field) andexact="search:field_name"
on the Results tag, making sure the given value exactly matches the field. Again, field_name should be replaced with the actual name of the target field.ngoncom 27 Mar 2018 10:04
Thank you so much, master!
I add hidden field to low_search:form and it work!
Another way is add parameter to {exp:low_search:results exact="search:data_quarter" ...}, it work, too!
And the last question, can I add conditional to {exp:low_search:results ...}, do you think the code below should work?
I am not test this case.
Thank for your time!
Low 27 Mar 2018 10:08
No, a conditional like that won't work and isn't necessary to begin with.
The
exact="search:data_quarter"
parameter doesn't do anything if no search:data_quarter parameter was submitted or part of the query. You can leave it on the Results tag without a problem.ngoncom 27 Mar 2018 10:12
That all make sense, I appreciate your help!