All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Condition with Low Search status not work

ngoncom 12 Aug 2018 21:03 question, complete

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

  1. Low 13 Aug 2018 06:52

    status is a native parameter. So follow these rules.

    Also, best practice dictates to use conditionals like this:

    {if low_search_status == 'open'}

  2. 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!

  3. 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:

    {exp:low_search:form query="{segment_2}"} 
    <select name="status">
    <option value="open"{if low_search_status == 'open'} selected>Open</option>
    <option value="closed"{if low_search_status == 'closed'} selected>Closed</option>
    ...
    </select>
    {/exp:low_search:form}

  4. ngoncom 13 Aug 2018 07:15

    Hi Low,

    Nothing changed!

    Here is the code:

    {exp:low_search:form query="{segment_1}" result_page="/filter"} 
    <select name="search:status">
    <option value="open" {if '{low_search_status}' == 'open'}selected{/if}>Open</option>
    <option value="closed" {if '{low_search_status}' == 'closed'}selected{/if}>Closed</option>
    </select>
    {/exp:low_search:form}

    When submit form, url is:

    /filter?search:status=closed

    Search results ok but the conditional

    {if '{low_search_status}' == 'closed'}selected{/if}

    not working.

  5. Low 13 Aug 2018 07:20

    The name of your status parameter is wrong. It's not search:status, it's just status, like the native parameter.

    Since you're using GET vars, you don't need the query parameter.

    So, use <select name="status"> and the conditional

    {if low_search_status == 'open'}


    And make sure you test it with /filter?status=open in the URL.

  6. 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!

  7. 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.

  8. 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!

  9. Low 13 Aug 2018 07:37

    Then, as I suggested, try this instead

    {exp:low_search:results default:status="not fake_status"...


    That way it won't override the given status in from the form.

  10. 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!