Re: [SMARTY] Is there an elegant way to do changing row-colors in Smarty-templates?

From: Date: Sat, 04 Oct 2003 14:43:22 +0000
Subject: Re: [SMARTY] Is there an elegant way to do changing row-colors in Smarty-templates?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10297@lists.php.net to get a copy of this message
you're putting the cart before the horse, mate ;) just use {cycle} as proposed by yourself, it's pretty easy and way cleaner: {cycle name="tr" values="#E69191,#FFFFFF"} {cycle name="td" values="textwhite,text"} {section name=i loop=$members} <tr bgcolor="{cycle name="tr"}"> <td valign="top" class="{cycle name="td"}"> {$members[i].fname}&nbsp;{$members[i].lname}<br> </td> </tr> {/section} cheers, David On Saturday, October 04, 2003 4:24 PM +0200, Kevin Coyner wrote: > I did it in a section loop, but should be the same logic and effect: > > {section name=i loop=$members} > {if $smarty.section.i.index is even} > <tr bgcolor="#E69191"> > <td valign="top" class="textwhite"> > {else} > <tr bgcolor="#FFFFFF"> > <td valign="top" class="text"> > {/if} > {$members[i].fname}&nbsp;{$members[i].lname}<br> > </td> > </tr> > {/section} > > This worked for me. I'm new to Smarty, but I think you'd could also > do this with the {cycle} function. Haven't tried it yet, but suspect > it will work and be a little cleaner. > > Kevin > > -- > Kevin Coyner > mailto: kevin@rustybear.com > GnuPG key: 1024D/8CE11941

« previous php.smarty.general (#10297) next »