Re: [SMARTY] Splitting an array into rows

From: Date: Thu, 13 Feb 2003 19:18:19 +0000
Subject: Re: [SMARTY] Splitting an array into rows
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7741@lists.php.net to get a copy of this message
yes, split your data into columns. http://smarty.php.net/contribs/examples/dynamic_table_columns/table.tpl.txt On Thu, 2003-02-13 at 12:24, James Burrows wrote: > I have an array, populated in my php script, that I can use in a smarty > template like so: - > > {foreach item=game from=$results} > <tr> > <td width="15" valign="top">{$game.pos}<td> > <td valign="top">{$game.name}</a></td> > <td width="40" valign="top>{$game.publisher}</td> > </tr> > {/foreach} > > This writes each game item into a row in a table. Now say I want to write 3 > games per row (in 3 <td>'s next to each other in the row. If there are any > left over (e.g. if the total number of games is 11 there would be 3 rows of > 3 games and 1 row of 2 games). > > Is there an easy way in smarty to accomplish this? > > Any help would be appreciated! > > Cheers, > James -- Monte Ohrt <monte@ispi.net>

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