Total/all results conditional
Is there a conditional / way to check if all results/entries have been returned (if a blank search was done for example)?
Something like:
[if total_results == absolute_results] No categories selected. All entries returned. [/if]
Replies
Low 7 Mar 2014 07:58
Well, not exactly. But you can check if there is a query present in the URI. For example:
{exp:low_search:results{if segment_2}query="{segment_2}"{/if}
status="not closed"
}
{if count == 1}
{if segment_2 == ''}All entries returned{/if}
{/if}
...
{/exp:low_search:results}
Garabedium 7 Mar 2014 15:15
Would that work even if encode query is disabled?
I'm using categories and dropdown selects for search:
http://pastebin.com/TVKA6dcM
So the URL ends up being: /search/results?require_all=category for a blank search (no categories selected).
Low 7 Mar 2014 15:26
Ah, no. But if you move the require_all="category" parameter to the Results tag instead of having it in your form (which by the looks of it is perfectly possible) you can use {if current_query_string == ''}All entries returned{/if} instead.
Garabedium 7 Mar 2014 15:42
That's exactly what I needed! Thanks!
Moving the require_all parameter to results and using current_query_string did the trick.