ExpressionEngine® Answers Asked by Tim Jukes on November 5, 2021
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:
<select style="width:200px;" name="status[]" >
<option value="Completed">Completed</option>
<option value="Shortlisted">Shortlisted</option>
<option value="Winner">Winner</option>
</select>
My results tag looks like this
{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}"
}
(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!
Note: I also posted this question here: https://getsatisfaction.com/low/topics/low_search_status_example
For anyone who's interested, here's how I've just implemented a Status search option in my Orders search form:
{exp:low_search:form query="{segment_3}" result_page="orders/search-results" channel="orders" status="Processing|Awaiting Payment|Complete|Cancelled"}
<div class="searchbar">
<input type="text" name="search:title" value="" placeholder="Order No" />
<select name="status[]">
<option value="not open|closed">Status</option>
<option>Processing</option>
<option>Awaiting Payment</option>
<option>Complete</option>
<option>Cancelled</option>
</select>
<input type="text" name="search:order_billing_first_name" value="" placeholder="First name" />
<input type="text" name="search:order_billing_last_name" value="" placeholder="Surname" />
<input type="text" name="search:order_billing_city" value="" placeholder="Town" />
<input type="text" name="search:order_billing_zip" value="" placeholder="Postcode" />
<button type="submit">Search</button>
</div>
{/exp:low_search:form}
And here is how my Results page is output:
{exp:low_search:results query="{segment_3}" channel="orders" {if status == ""}status="Processing|Awaiting Payment|Complete|Cancelled"{/if} limit="20"}
{if no_results}<p>No results matched your query.</p>{/if}
Order: {title}
Status: {status}
Name: {order_billing_first_name} {order_billing_last_name}
Address: {order_billing_city} {order_billing_zip}
Total: £{order_total}
Date: {entry_date format="%l %j%S %F %Y %g:%i %a"}
{/exp:low_search:results}
Answered by IC360 Oliver Cannell on November 5, 2021
I'll answer here as well as in the GetSat thread for visibility.
Any parameters set in the Results tag will always overwrite the corresponding given parameters from a search query. If you want to default a certain value, you could use simple conditionals to check for an encoded query in the URI and set certain parameters accordingly. For example:
{exp:low_search:results
query="{segment_3}"
{if segment_3 == ''}status="not closed|In progress"{/if}
}
In addition to that, if you want 'All' entries to exclude certain values, just define those in the 'All' option of the drop down. For example:
<select name="status">
<option value="not closed|In progress">All</option>
<option>Completed</option>
<option>Shortlisted</option>
<option>Winner</option>
</select>
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.
Also note you don't need the multiple value syntax in the name (status[]
), as you're only selecting a single value.
Answered by Low on November 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP