Home > Archive > PHP Smarty Templates > May 2004 > Re: [SMARTY] How can one create a table dynamically with Smarty ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [SMARTY] How can one create a table dynamically with Smarty ?
|
|
| Gabriel Birke 2004-05-04, 4:05 pm |
| Haven't tested this but it should give you the general idea on how to=20
accomplish a table:
<table>
{section loop=3D$data name=3Di}
<tr><td>{$data[i].image}</td><td>{$data[i].description}</td></tr>
{/section}
</table>
With best regards
Gabriel Birke
--=20
KONTOR4_Neue Medien
Plathnerstra=DFe 5
30175 Hannover
Fax: +49 51184 48 98 99
mailto:birke@kontor4.de
http://www.kontor4.de
Am 30.04.2004 um 12:29 schrieb Pete:
> Hi there,
>
> I have an array containing the image name and description accessible=20=
> though
> $data[i].image and $data[i].description in a smarty {section}.
>
> I just don't understand how i can dynamically create a table in smarty=20=
> that
> has lets say two columns.
> Would anybody be so kind to explain to me how to do it ?
>
> Thank you very much.
>
> --=20
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
| |
|
| Hi Gabriel,
thank you very much for the reply.
Unfortunately that doesn't help at all.
The problem is that a multi column table is needed.
The code below will only produce a table with one column.
<table>
{section loop=$data name=i}
<tr><td>{$data[i].image}</td><td>{$data[i].description}</td></tr>
{/section}
</table>
Thx anyway and have a nice w end!!
Regards Pete
| |
| Monte Ohrt 2004-05-04, 4:05 pm |
| It looks like two columns to me. ??
<table>
<tr>
<td>column 1</td>
<td>column 2</td>
</tr>
</table>
Pete wrote:
>Hi Gabriel,
>
>thank you very much for the reply.
>Unfortunately that doesn't help at all.
>The problem is that a multi column table is needed.
>The code below will only produce a table with one column.
>
><table>
>{section loop=$data name=i}
><tr><td>{$data[i].image}</td><td>{$data[i].description}</td></tr>
>{/section}
></table>
>
>Thx anyway and have a nice w end!!
>
>Regards Pete
>
>
>
| |
|
| Great guys,
Thank you very much!!!
All the best and have a nice w end!!!
Pete
| |
|
|
Unfortunately this code doesn't work either:
<table>
<tr>
{section loop=$data name=i}
<td><a href="../images/company/einblicke/{$data[i].picture}"
target="_blank"><img
src="../images/company/einblicke/{$data[i].thumb}"></a><br />
{$data[i].descr}</td>
{if $smarty.section.i.index is div by 2 && $smarty.section.i.index != 0}
</tr>
<tr>
{/if}
{/section}
</tr>
</table>
There seem to be 3 colums
The first row has 3 pictures all others have 2. I can't figure out why this
is.
in this case $data is an 2dimensional array, as you will get it when
reading
some rows from a database. each row is an array stored as element of
another
one so here.
The 1st dimension i walk through with the section, the second one with
the foreach, because its associative.
hth
Ben
-----Ursprüngliche Nachricht-----
Von: Pete [mailto:webmaster@dentona.de]
Gesendet: Freitag, 30. April 2004 15:50
An: smarty-general@lists.php.net
Betreff: Re: [SMARTY] How can one create a table dynamically with Smarty
?
Hi Gabriel,
thank you very much for the reply.
Unfortunately that doesn't help at all.
The problem is that a multi column table is needed.
The code below will only produce a table with one column.
<table>
{section loop=$data name=i}
<tr><td>{$data[i].image}</td><td>{$data[i].description}</td></tr>
{/section}
</table>
Thx anyway and have a nice w end!!
Regards Pete
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
________________________________________
__________________
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28.04.2004
---
________________________________________
__________________
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28.04.2004
| |
| Messju Mohr 2004-05-04, 4:05 pm |
| On Tue, May 04, 2004 at 12:23:42PM +0200, Pete wrote:
>
> Unfortunately this code doesn't work either:
>
> <table>
> <tr>
> {section loop=$data name=i}
> <td><a href="../images/company/einblicke/{$data[i].picture}"
> target="_blank"><img
> src="../images/company/einblicke/{$data[i].thumb}"></a><br />
> {$data[i].descr}</td>
> {if $smarty.section.i.index is div by 2 && $smarty.section.i.index != 0}
should read: "is div by 3", not?
> </tr>
> <tr>
> {/if}
> {/section}
> </tr>
> </table>
>
> There seem to be 3 colums
> The first row has 3 pictures all others have 2. I can't figure out why this
> is.
>
>
> in this case $data is an 2dimensional array, as you will get it when
> reading
> some rows from a database. each row is an array stored as element of
> another
> one so here.
> The 1st dimension i walk through with the section, the second one with
> the foreach, because its associative.
>
> hth
> Ben
>
>
> -----Ursprüngliche Nachricht-----
> Von: Pete [mailto:webmaster@dentona.de]
> Gesendet: Freitag, 30. April 2004 15:50
> An: smarty-general@lists.php.net
> Betreff: Re: [SMARTY] How can one create a table dynamically with Smarty
> ?
>
>
> Hi Gabriel,
>
> thank you very much for the reply.
> Unfortunately that doesn't help at all.
> The problem is that a multi column table is needed.
> The code below will only produce a table with one column.
>
> <table>
> {section loop=$data name=i}
> <tr><td>{$data[i].image}</td><td>{$data[i].description}</td></tr>
> {/section}
> </table>
>
> Thx anyway and have a nice w end!!
>
> Regards Pete
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> ---
> ________________________________________
__________________
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.672 / Virus Database: 434 - Release Date: 28.04.2004
>
>
> ---
> ________________________________________
__________________
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.672 / Virus Database: 434 - Release Date: 28.04.2004
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
| |
| Messju Mohr 2004-05-04, 4:05 pm |
| On Tue, May 04, 2004 at 12:30:30PM +0200, messju mohr wrote:
> On Tue, May 04, 2004 at 12:23:42PM +0200, Pete wrote:
>
> should read: "is div by 3", not?
correction:
{if $smarty.section.i.iteration is div by 3 && !$smarty.section.i.last && $smarty.section.i.index != 0}
and of course this one is missing some handling of the number of
entries is not dividable by the number of columns.
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
| |
|
| Hi,
> correction:
> {if $smarty.section.i.iteration is div by 3 && !$smarty.section.i.last &&
$smarty.section.i.index != 0}
>
> and of course this one is missing some handling of the number of
> entries is not dividable by the number of columns.
So how do I fix this ? Really, I have no idea. I have spent the last 2 days
on this problem.
http://learn.to/quote
| |
| Messju Mohr 2004-05-04, 4:05 pm |
| On Tue, May 04, 2004 at 12:50:21PM +0200, Pete wrote:
> Hi,
>
> $smarty.section.i.index != 0}
>
> So how do I fix this ? Really, I have no idea. I have spent the last 2 days
> on this problem.
read the fine FAQ maybe:
http://smarty.incutio.com/? page=Sm...p
late-12
> http://learn.to/quote
don't like my quoting? then don't read my posts.
|
|
|
|
|