EllisLab text mark
Advanced Search
     
Multi-column layout with switch
Posted: 26 July 2012 01:56 PM   [ Ignore ]
Avatar
Joined: 2008-05-15
313 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.

 Signature 

“It works on my machine!”

 
Posted: 26 July 2012 03:39 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-03-22
12298 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>
    
{body}
  
</div>
{/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

 Signature 

John Henry’s Website | Follow me on Twitter

 
Posted: 26 July 2012 05:40 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-15
313 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?

 Signature 

“It works on my machine!”

 
Posted: 26 July 2012 05:43 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-15
313 posts

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

Guess I should have tried it first! smile

Thanks for the idea.

 Signature 

“It works on my machine!”

 
Posted: 26 July 2012 05:47 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2004-03-22
12298 posts

Good stuff! Glad it worked for you

 Signature 

John Henry’s Website | Follow me on Twitter