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 Conditionals to Generate DIV with Entries

August 09, 2011 4:16pm

Subscribe [3]
  • #1 / Aug 09, 2011 4:16pm

    mmcgeeCC

    17 posts

    Preface: I’ve created a jQuery scroller like the one found here: http://flowplayer.org/tools/demos/scrollable/index.html. Think of each image as an entry in one channel. My issue is not getting the scroller to work, but getting ExpressionEngine to display DIVs or not.

    The code that I wish would work, but obviously doesn’t, is below. Note my wish to use the conditionals where they are, which would mean that if there are more than 4 entries, show another div.viewableWindow and show entries. If not, then don’t. Anyone know how I can achieve something like this?

    <div class="window">
    
         <div class="viewableWindow">
              {exp:channel:entries channel="my-channel" status="open" limit="4" disable="pagination" orderby="expiration_date" sort="asc"}
                   {entry-image}
              {/exp:channel:entries}
         </div>
    
         {if count > 4}
         <div class="viewableWindow">
              {exp:channel:entries channel="my-channel" status="open" limit="4" offset="4" disable="pagination" orderby="expiration_date" sort="asc"}
                   {entry-image}
              {/exp:channel:entries}
         </div>
         {/if}
    
         {if count > 8}
         <div class="viewableWindow">
              {exp:channel:entries channel="my-channel" status="open" limit="4" offset="8" disable="pagination" orderby="expiration_date" sort="asc"}
                   {entry-image}
              {/exp:channel:entries}
         </div>
         {/if}
    
    </div>

    Thanks for your help.
    EE v2.2.2 - Build: date 20110801

    Moved to Community Help forum by Moderator

  • #2 / Aug 09, 2011 6:28pm

    mmcgeeCC

    17 posts

    I tried an alternative, but it doesn’t seem to be working either.

    My Embedded Template

    {exp:channel:entries channel="my-channel" status="open" limit="{embed:myLimit}" offset="{embed:myOffset}" disable="pagination" orderby="expiration_date" sort="asc"}
         {entry-image}
    {/exp:channel:entries}

    My Template

    {exp:channel:entries channel="my-channel" status="open" disable="pagination"}
    
       <div class="viewableWindow">
         {embed="includes/my-include" myLimit="4" myOffset="0"}
       </div>
    
       {if count > 4}
       <div class="viewableWindow">
         {embed="includes/my-include" myLimit="4" myOffset="4"}
       </div>
       {/if}
                            
       {if count > 8}
       <div class="viewableWindow">
         {embed="includes/my-include" myLimit="4" myOffset="8"}
       </div>
       {/if}
    
    {/exp:channel:entries}
  • #3 / Aug 10, 2011 10:04am

    Sue Crocker

    26054 posts

    Hi, mmcgeeCC - this is a perfect candidate for the Community Help forum, moving there for additional community support.

  • #4 / Aug 10, 2011 12:10pm

    Elemento, Inc.

    57 posts

    Hi i would use this:

    <div> // you need to have an open div
    
    {exp:channel:entries}
    
    [...CONTENT GOES HERE…]
    
    {switch="|||</div><div>"} // this will add a close/open DIV every fourth entry
    
    {/exp:channel:entries}
    </div> // you need to have a closed div
  • #5 / Aug 10, 2011 5:33pm

    mmcgeeCC

    17 posts

    Nice… worked like a charm. Thanks for the help!

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

ExpressionEngine News!

#eecms, #events, #releases