Splitting rows with Smarty
| From: | Radu-Mihail Obada | Date: | Wed, 18 Dec 2002 14:52:51 +0000 |
| Subject: | Splitting rows with Smarty | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-6873@lists.php.net to get a copy of this message | ||
Hi,
Say I have two variables avaiable in my Smarty template, let them be
called $rowSplit and $images. I want to display the things stored in
$images (which is an array) in a table, but I want the table to have no
more than $rowSplit columns per row. And the question is: is there a way
to achieve this in _the template_ code? For example, is it possible to do
something like:
{* this is not valid Smarty code *}
<table>
{foreach from=$images item=image key=index}
{if $index is div by $rowSplit}
<tr>
{/if}
{* OK, the part with the opening TR tag works *}
{* but what to do with the closing tag? *}
{* display cells with TD *}
{if $index % $rowSplit eq $rowSplit -1} {* This doesn't work *}
</tr>
{/if}
{/foreach}
</table>
?
Thanks in advance,
Radu