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.

Multi-column layout with switch

July 26, 2012 1:56pm

Subscribe [2]
  • #1 / Jul 26, 2012 1:56pm

    The Design Core

    359 posts

    I have a multi-column layout that is supposed to only display items that are set to a certain type.

    There is a custom field that lets you select whether the entry is an event or an offer.

    So within my entries loop, I have {if event_type == "offer"} which only displays entries set to be an offer.

    Then I use {switch='floatleft|floatright'} to set the class of a div to create the columns.

    The problem I have is that since not all entries are offers, the loop is still counting the entries that don’t get displayed so the switch statement does not work correctly and the visible entries do not alternate between floatleft & floatright.

    Hope that makes sense.

    Any help is appreciated.

  • #2 / Jul 26, 2012 3:39pm

    John Henry Donovan

    12339 posts

    Hi mediapimp,

    You could eliminate the conditional altogether and use the search parameter like so

    {exp:channel:entries channel="products" search:event_type="=offer" dynamic="no"}
      
     <div class="{switch='floatleft|floatright'}">
       <h2>{title}</h2>
    <p>    {body}<br />
      </div><br />
    {/exp:channel:entries}

    Note: Only fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.

    Hope that helps

    John Henry

  • #3 / Jul 26, 2012 5:40pm

    The Design Core

    359 posts

    Good suggestion but I’m not using the EE entries tag. I’m using the calendar:events tag from Solspace’s Calendar add-on.

    Any other thoughts?

  • #4 / Jul 26, 2012 5:43pm

    The Design Core

    359 posts

    Actually, the search parameter works in their calendar:events tag!!

    Guess I should have tried it first! 😊

    Thanks for the idea.

  • #5 / Jul 26, 2012 5:47pm

    John Henry Donovan

    12339 posts

    Good stuff! Glad it worked for you

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

ExpressionEngine News!

#eecms, #events, #releases