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

From: Date: Sat, 04 Oct 2003 14:24:50 +0000
Subject: Re: [SMARTY] Is there an elegant way to do changing row-colors in Smarty-templates?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10295@lists.php.net to get a copy of this message
On Sat, Oct 04, 2003 at 02:50:47PM +0200, Jan Skopek wrote...... > Does anybody know an elegant way to change the bg-color of an tablerow > within in an foreach-loop? > Imagine this: > > <table> > {foreach from=$foo item=bar} > <tr bgcolor="{$color...?}"> > <td>{$bar}</td> > </tr> > {/foreach} > </table> > > Thank a lot for anwers! 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 (#10295) next »