x
 
Create New Page
 View Previous Changes    ( Last updated by mArsmAn )

Use switch on categories

If you want to use something like the switch variable in the categories tag you can use this php snippet

<?php echo ({count} % 2)? "row_one" : "row_two"; ?>

the result returns 1 or 0, so it is always true or false, “row_one” or “row_two”.

When you need more then 2 different row styles you can increase the integer but you will need a switch statement, like

<?php
switch ({count} % 5){
    
case 1:
        echo
"row_one";
        break;
    case
2:
        echo
"row_two";
        break;
    case
3:
        echo
"row_three";
        break;
    case
4:
        echo
"row_four";
        break;
    default:
        echo
"row_five";
        break;
}
?>

Category:Categories

Categories: