Re: [SMARTY-DEV] Newbie Coding Question

From: Date: Fri, 21 Feb 2003 15:18:47 +0000
Subject: Re: [SMARTY-DEV] Newbie Coding Question
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-802@lists.php.net to get a copy of this message
A better syntax to do this: {if (%item.rownum% % 2) == 0} class="alt" {/if} would be this {if $smarty.section.rownum is even} class="alt" {/if} and even easier way to do this particular task: <td class="{cycle values="odd,even"}"> would end up rendering like this: <td class="odd"> <td class="even"> <td class="odd"> ... Monte On Fri, 2003-02-21 at 01:06, andreas halter wrote: > Eric Hilding told me on Friday 21 February 2003 06:46: > > This is some PHP code to display alternating color rows for output > > for 3 fields. I would appreciate it greatly if anyone could help me > > (us) see how the .php and .tpl files should look which will be a > > great learning tool (and for practical use but with many more > > fields). > > hmm > > 1. write html tags lowercase > > 2. script.php [untested] > <?php > $o=new Smarty; > $o->assign('ROWS',$array_with_rows_collection); > $o->display('templ.tpl'); > ?> > > 3. templ.tpl [untested] > <table> > {section name=item loop=$ROWS} > <tr> > <td {if (%item.rownum% % 2) == 0} class="alt" {/if}> > {$ROWS.item.value} > </td> > </tr> > {/section} > </table> > > but there's a bunch of other ways to do so, have a look at the doc. > -- > www.andreashalter.ch > futurama: 'file deletion is murder!' -- Monte Ohrt <monte@ispi.net>

« previous php.smarty.dev (#802) next »