Low search status example
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
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":
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}
?Low 2 Jun 2013 08:13
You can check for the presence of an encoded query in the URL and set the parameter accordingly:
To get the status selected, use the parameter name prefixed with low_search_. So:
And as a conditional, you can use: