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

Support archive

How can I show no results when search field is blank?

ZenBug 27 Jul 2016 15:38 question, complete

This is a new topic based on this comment:
https://getsatisfaction.com/low/topic...

I am encoding queries. When I leave the Keywords field blank and hit the Search button, I get all entries as the result. I'd like to have it return no results in this case. In other words, if I search for nothing, I should find nothing (as opposed to everything).

Is there a way to accomplish this? I assumed the low_search_no_results conditional would do it, but it doesn't seem to be working.

Replies

  1. Low 27 Jul 2016 15:52

    The thing is here, there *is* a query, it just doesn't contain any keywords. The encoded query in the URL isn't empty, so the no_results isn't triggered when the Results tag contains require_query="yes". Note, in LS terms, a query != keywords. Rather, a query can contain keywords and any other amount of parameters.

    I reckon you're after setting required="keywords" on the Form tag, so the form won't allow empty keywords to be submitted.

  2. ZenBug 27 Jul 2016 16:32

    Ah, I see. Thanks for the schooling, and yes, required="keywords" does the trick.

    Thanks as always, Low!