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.

using count in a conditional...

March 08, 2012 4:36pm

Subscribe [2]
  • #1 / Mar 08, 2012 4:36pm

    TGP

    78 posts

    I could have sworn I had something similar setup on another site, but I can’t find it now…basically I want to use a conditional to add some html to the output of a channel loop every 3rd time through the loop…

    I tried something like below…but this doesn’t work, probably because I set multiple numbers with the pipe.

    {exp:channel:entries channel="enewsletter_issue" sort="asc" dynamic="no"}
    
       {if count == "1|3|5"}
       <div class="row">
       {/if}
        <article>
         {exp:ce_img:single src="{art_image}" width="53" height="53" crop="yes"}
         <h1><a href="http://{title_permalink=enewsletter/article}">{title}</a></h1>
        </article>
       {if count == "2|4|5"}
       </div>
       {/if}
       {/exp:channel:entries}

    This works, but only one time and I need to be able to do it multiple times…

    {exp:channel:entries channel="enewsletter_issue" sort="asc" dynamic="no"}
    
       {if count == "1"}
       <div class="row">
       {/if}
        <article>
         {exp:ce_img:single src="{art_image}" width="53" height="53" crop="yes"}
         <h1><a href="http://{title_permalink=enewsletter/article}">{title}</a></h1>
        </article>
       {if count == "2"}
       </div>
       {/if}
       {/exp:channel:entries}

    Any thoughts?

     

  • #2 / Mar 08, 2012 4:40pm

    TGP

    78 posts

    And I realize I can use OR like below, but it seems a little messy…

    {if count == "1" OR count == "2" OR count == "3"}
  • #3 / Mar 10, 2012 12:01pm

    Man With A Peg

    124 posts

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

ExpressionEngine News!

#eecms, #events, #releases