Spreading Knol
Search This Blog
Tuesday, February 15, 2011
cycle odd and even in Smarty
{foreach from=$menu_items item=i name=menu_items}
{if $smarty.foreach.menu_items.first}
{cycle values='odd,even'} first">
{elseif $smarty.foreach.menu_items.last}
{cycle values='odd,even'} last">
{else}
{/if}
{$i.title}
{/foreach}
Mostly we use to apply alternate colors for table rows to do that we will use mod operator or if else condition to overcome this above method can be used it will rotate the values and assign to class we can have "n" number of values inside the cycle
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Subscribe To Sundar's Blog
Posts
Atom
Posts
Comments
Atom
Comments
No comments:
Post a Comment