I’m trying to loop through entries and on every 5th one change a class in a li tag,if I use:
<?php
for($i=0;$i<10;$i++){
?>
<?php
if($i % 5){
?>
<li class="start">
{title}
</li>
<?php }else{ ?>
<li class="end">
{title}
</li>
<?php } ?>
<?php } ?>So basically this just doesn’t work :( I do get that it wont work with entries, it is a loop already, but how can I do the above in EE? Thanks
Are you referring to EE’s {switch} tag? I’m not sure I understand the question - but you can use the {switch} tag like this:
<li class="{switch='one|two|three|four|five'}">In a 10 entry result, that would print the word “one” on the 1st and 6th entry, the word “two” in the 2nd and 7th entry, etc.
That in mind, you can leave the first 4 empty to just have something printed each 5th entry:
<li class="{switch='||||five'}">Edit: I forgot to hit submit then noticed you got an answer already 😊
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.