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

Support archive

Show specific HTML based on the number of results

Heiko 17 Jul 2012 14:29 question, complete

This one's not directly product-specific, but I have the following problem bugging me for quite some time and noone seems to be able to solve it:

I want to show this simple jQuery-filter-module on my search results page, but only if there are 10 or more results:

http://pastie.org/4271952

Now, I can't put it inside of the channel_entries or low_search:results tags, because then it will be repeated with each entry.

Of course it wouldn't be a real problem, if the module was there all the time, but in the case of no_results, it's not only inelegant to have it show up, but it messes up my DOM-tree.

So, does anybody now how to show this module based on the number of entries or at least, if there are any entries at all?

Replies

  1. Low 17 Jul 2012 14:33

    Couldn't you just put it in the channel:entries or low_search:results tag and use a conditional? Something like:

    {if total_results >= 10 AND count == 1} 
    this only appears with 10 or more entries,
    and only for the first entry
    {/if}

  2. Heiko 17 Jul 2012 15:06

    Man, you are such a life saver, I'll buy every friggin' addon just to support you! ;)

    It seems I didn't know about the count == 1-"stuff" and it works perfectly!

    Thanks again!