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

Support archive

Low search status example

timjukes 1 Jun 2013 11:09 question, complete

Hi - I wondered if there was an example of using statuses as a dropdown? I'm trying to search by a couple of options with not much success. I want to filter by some statuses but never show items in another status.

My dropdown currently looks like this:

[code]

Completed
Shortlisted
Winner

[/code]

My results tag looks like this

[code]
{exp:low_search:results
channel="applications|bursary_applications"
status="not closed|In progress"
query="{segment_3}"
dynamic="off"
limit="50"
paginate="bottom"
collection="applications|bursary_applications"
child:bursary_app_competition_rel="{segment_2}"
}
[/code]

(when the page is first loaded without search terms I want to make sure 'In progress' is not shown - or I'd settle for a default of 'Completed'!)

Many thanks!

Replies

  1. Low 1 Jun 2013 13:15

    Hardcoded parameters in the Results tag will always overwrite the parameters given in the Form. So you could default a "blank" option to "not closed|In progress":

    <select name="status"> 
    <option value="not closed|In progress">All</option>
    <option>Completed</option>
    <option>Shortlisted</option>
    <option>Winner</option>
    </select>

    Low 1 Jun 2013 13:17

    Note that if you don't add a value-attribute to an option-element, the text inside the option-element will be used as value.

  2. timjukes 1 Jun 2013 14:41

    Thanks, that's great. What's the default behavior meant to be when visiting the page for the first time? Are any results meant to show if the form's not been submitted? Is there a way to control the default options without hardcoding them in the results tag?

    Also wondered what the best way to code the conditional to make the current option selected - would it be on {if {'low_search:status'} == 'Completed'}selected{/if} ?

  3. Low 2 Jun 2013 08:13

    You can check for the presence of an encoded query in the URL and set the parameter accordingly:

    {exp:low_search:results 
    query="{segment_3}'
    {if segment_3 == ''}status="not closed|In progress"{/if}
    }


    To get the status selected, use the parameter name prefixed with low_search_. So:

    {low_search_status}


    And as a conditional, you can use:

    {if '{low_search_status}' == 'Completed'} ... {/if}