Condition with Low Search status not work
Hi Low,
I using this code, it work:
{exp:low_search:form ...}
<select name="search:status">
<option value="not closed">All</option>
<option value="open" {if 'open' == '{low_search_status}'}selected{/if}>Open</option>
<option value="closed" {if 'closed' == '{low_search_status}'}selected{/if}>Closed</option>
</select>
{/exp:low_search:form}
But the conditional:
{if 'open' == '{low_search_status}'}selected{/if}
not work, even I using another variable: {low_search_status},
{low_search_search:status}, {low_search:status}
Thank!
Replies
Low 13 Aug 2018 06:52
status
is a native parameter. So follow these rules.Also, best practice dictates to use conditionals like this:
ngoncom 13 Aug 2018 07:01
Hi Low,
It not working, even I have tried:
{if low_search_status == 'open'} // return error parsing
or
{if '{low_search_status}' == 'open'} // not return conditional
I tested on EE 2.11.9 and Low Search 4.4.5
Thank!
Low 13 Aug 2018 07:05
Make sure that you add the query="" parameter to the Form tag, so Low Search knows what's been submitted.
So, if your encoded query is in segment 2:
ngoncom 13 Aug 2018 07:15
Hi Low,
Nothing changed!
Here is the code:
When submit form, url is:
Search results ok but the conditional
not working.
Low 13 Aug 2018 07:20
The name of your status parameter is wrong. It's not
search:status
, it's juststatus
, like the native parameter.Since you're using GET vars, you don't need the query parameter.
So, use
<select name="status">
and the conditionalAnd make sure you test it with /filter?status=open in the URL.
ngoncom 13 Aug 2018 07:27
If I using
<select name="status">
Conditional WORKING! But result page return ALL entries, not entries have status=open
Thank!
Low 13 Aug 2018 07:29
Make sure there's no status="" parameter on the Results tag, as that will override the parameter. You can use default:status="not closed" on the Results tag instead.
ngoncom 13 Aug 2018 07:35
Yes!
I set status="not fake_status" to ensure that entries have status=closed still display.
{exp:low_search:results status="not fake_status"...
The results still return ALL entries!
Low 13 Aug 2018 07:37
Then, as I suggested, try this instead
That way it won't override the given status in from the form.
ngoncom 13 Aug 2018 07:45
Oh my God!
I dont think have this parameter:
default:status="..."
IT WORKS!
Today I spend your time too much, thank for teaching me.
God bless you!