ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Evaluating for # of results

June 23, 2007 6:40pm

Subscribe [1]
  • #1 / Jun 23, 2007 6:40pm

    hothousegraphix

    851 posts

    I’m assuming the {total_results} variable will allow me to to do the following:

    {exp:weblog:entries weblog="yourweblog"}
    <div class="top">
    {if '{total_results}' >= 3}
    <h1>Show this heading if 3 or more results exist</h1>
    {if:else}
    <h1>Show this heading less then 3 results exist</h1>
    {/if}
    {body}
    </div>
    {/exp:weblog:entries}

    ???

  • #2 / Jun 24, 2007 5:43pm

    Robin Sowell

    13255 posts

    Try it like:

    {exp:weblog:entries weblog="yourweblog"}
    <div class="top">
    {if count == 1}
    {if total_results >= 3}
    <h1>Show this heading if 3 or more results exist</h1>
    {if:else}
    <h1>Show this heading less then 3 results exist</h1>
    {/if}
    {/if}
    {body}
    </div>
    {/exp:weblog:entries}

    Two differences- first, proper syntax on the conditional- second, the additional if count bit makes sure the header only shows up once- instead of each time.  But the basic logic is solid.

  • #3 / Jun 24, 2007 5:51pm

    hothousegraphix

    851 posts

    Robin, thanks very much for the advice…this is quite useful.

    Enjoy the balance of your weekend.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases