Re: How to do two column list using section?
| From: | Monte Ohrt | Date: | Sat, 03 Mar 2001 15:00:05 +0000 |
| Subject: | Re: How to do two column list using section? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-273@lists.php.net to get a copy of this message | ||
easy ;-)
{section name=list loop=$data}
{if %list.first%}
{* first record, start table row *}
<tr>
{/if}
{* display our cell data *}
<td>{$list/data}</td>
{if %list.last%}
{* last record, close row *}
</tr>
{elseif %list.index% even by 2}
{* record even by 2, start a new row *}
</tr><tr>
{/if}
{/section}
%list.first% and %list.last% are new in 1.3.1 (not released yet),
so for now you can use this work around (untested ;-):
%list.first% alternative:
{if %list.index% eq 0}
%list.last% alternative:
{if %list.rownum% eq %list.loop%}
Jim Harlindong wrote:
>
> Hello,
>
> another question...
>
> I want to display an array in two columns using table, e.g.
>
> data 1 | data 2
> data 3 | data 4
> data 5 | data 6
> ...
>
> using section.. how can this be done?
>
> the code would be something like
>
> {section name=list loop=$data}
> <tr>
> <td>{$list/data}</td>
> <td>{$list/data}</td>
> </tr>
> {/section}
>
> Also need to handle the situation where the second column is blank because
> the data ends at the first column.
>
> Thanks
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/