2.5.6. cycle()

mixed cycle ( ... )

Iterates through the specified parameters after each calling. For example, if we specify three values: 1, 2, 3, the function returns 1 after first calling, 2 after second, 3 after third, again 1 after fourth etc. Useful in design issues - in the example below we color in a different way each row of the table:

Example 2.14. cycle() function

<table border="0">
{section=rows}
{@class is cycle("bright", "dark")}
<tr>
  <td class="{@class}">{$rows.name}</td>
  <td class="{@class}">{$rows.value}</td>
</tr>
{/section}
</table>

Note: since OPT 1.1.0 cycle() is not necessary in this place. You can use section attributes:

Example 2.15. cycle() is not necessay

<table border="0">
{section=rows}
{cycle=class; bright; dark} {* internal section tag *}
<tr>
  <td opt:cycle="rows">{$rows.name}</td>
  <td opt:cycle="rows">{$rows.value}</td>
</tr>
{/section}
</table>

See sections for more details.