RE: [SMARTY] vaguely complicated tables
| From: | Chris Hubbard | Date: | Fri, 29 Aug 2003 15:39:22 +0000 |
| Subject: | RE: [SMARTY] vaguely complicated tables | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10155@lists.php.net to get a copy of this message | ||
Kerin,
I think you need to use the section tag:
http://smarty.php.net/manual/en/language.function.section.php
I can't quite discern the structure of your array from your example, so I
guessed.
Assuming the array looks like:
$arr[0][var][0]="foo";
$arr[0][var][1]="bar";
$arr[0][var][2]="boffa";
$arr[1][var][0]="foo";
$arr[1][var][1]="bar";
$arr[1][var][2]="boffa";
Then do something like:
<table>
{section name=rows loop=$arr}
<tr>
<td><div>
<img src="{$arr[rows].var[0]}" />
<p>{$arr[rows].var[1]}</p>
<p>{$arr[rows].var[2]}</p>
</div></td>
</tr>
{/section}
</table>
-----Original Message-----
From: Kerin Cosford [mailto:kerin@airside.co.uk]
Sent: Friday, August 29, 2003 5:43 AM
To: smarty-general@lists.php.net
Subject: [SMARTY] vaguely complicated tables
Hi,
This is my first stab at using Smarty, so bear with me. I've liked what
I've seen so far, and had no real problems, until I came to try and
display an associative array in a HTML table. I thought the html_table
function would do what I'm looking for, but that only seems to support a
table with one item of data per cell. What I'm looking to do is produce
a table that looks something like this :
<table>
<tr>
<td>
<div>
<img src="{$arr.var1}" />
<p>{$arr.var2}</p>
<p>{$arr.var3}</p>
</div>
</td>
<td>
<div>
<img src="{$arr.var1}" />
<p>{$arr.var2}</p>
<p>{$arr.var3}</p>
</div>
</td>
<td>
<div>
<img src="{$arr.var1}" />
<p>{$arr.var2}</p>
<p>{$arr.var3}</p>
</div>
</td>
</tr>
</table>
, with multiple rows.
Hopefully I'm missing something obvious, because at the moment, the only
way I can see that this is possible is to concatenate my array so that
it just contains multiple elements that combine all of my values, and
their HTML, which kind of defeats the purpose of trying to seperate
logic from display structure.
Anybody got any ideas?
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php