1

Im trying to show results after search so that if there is under 10, it shows A, but if there is more than 10 results, it shows B. But I dont understand how to make this happen.

I tried this but it wont work: {if count == '1'}<h4>total results: <span>{absolute_results}</span>.</h4>{if:elseif count > '10'}<h4>There is more than 10 results. Refine your search?</h4>{/if}

3

You've almost got it. {count} is the current count of the displayed entry in the tag's loop. Think of your entries as a numbered list, the {count} is the position in the list.

{absolute_results} however is total number of entries in the "list", so you want to build your conditional from it.

Here is one example using your markup:

{if count == 1}
    <h4>
        {if absolute_results > 10}
            There are more than ten results. Refine your search?
        {if:else}
            Total results: <span>{absolute_results}</span>
        {/if}
    </h4>
{/if}
2
  • Thank you. I wrapped that inside if count == 1 (to show it only on top of the page, and not above all listed entries) and now it works like a charm.
    – Riverboy
    May 19 '15 at 18:29
  • Ok, I've updated my answer to reflect that context. May 20 '15 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.