We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Switch and conditional

Development and Programming

Finn's avatar
Finn
40 posts
8 years ago
Finn's avatar Finn

The below doesn’t appear to work. The problem seems to be with the conditional. Splitting it into two separate conditionals yields the same results. Am I doing something wrong - is there perhaps a better way?

<!–Add a closing div tag every second entry, in order to close the row–> {switch='|</div>'}

<!–If the last row only has one entry, add a closing div tag so that the row is closed–> {if count == total_results AND “{switch='|</div>'}” != ‘</div>’} </div> {/if}

       
Finn's avatar
Finn
40 posts
8 years ago
Finn's avatar Finn

Found the answer here:

https://willowlightstudio.com/news/2016/the-switch-conundrum-closing-tags-with-switch-statements-in-expressionengin

And for 3 columns this works:

{if total_results % 3 != 0}</div>{/if}

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.