RE: [SMARTY] {section} with array that doesnt start with index 0
| From: | Peter Billen | Date: | Sun, 18 Aug 2002 20:24:37 +0000 |
| Subject: | RE: [SMARTY] {section} with array that doesnt start with index 0 | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5740@lists.php.net to get a copy of this message | ||
For those who don't understand my sucky english (sorry for that):
The point is that {section} wants to start with index 0, and that my
array doesn't start with index 0 (it does with index 1), so the
{section} loop forgets to display one row, for some strange reason.
Thanks,
Peter
-----Original Message-----
From: Peter Billen [mailto:peter@clueless.be]
Sent: zondag 18 augustus 2002 22:20
To: 'Smarty General'
Subject: [SMARTY] {section} with array that doesnt start with index 0
Hi all,
In my database, I have a list of gametypes. My first gametype has number
1, my second number 2, etc..
Uptill now, I used to have the {foreach} construction to display the
gametypes, and that worked perfectly.
But with the {foreach} loop, I had some layout errors: after every loop
I print a "<br>" (or something else). But I don't want that when the
foreach ends (so at the last loop). Since foreach doesn't support "{if
$smarty.section.games.last <> true}", I had to convert my foreach into a
section.
This is what I have now:
HTML:
<table width=625 border=0 cellspacing=0 cellpadding=0
bordercolor=#45728B>
{section name=games loop=$warListData start=0}
<tr>
..
..
{if $smarty.section.games.last <> true}
<tr><td align=left class=geel> </td></tr>{/if}
{/section}
</table>
PHP, my array:
array $warListData:
-> ['game_id'] (x)
-> ['game_name']
-> ['leagues'] (x)
-> ['league_id'] (x)
-> . (not important)
This works, however not for 100%. The problem is that the section
forgets one loop. After some debugging, I tried to change to give last
gametype index 0, instead of 13, and it worked perfectly.
However, changing the primary keys of my gametypes in my dbase into a
non-standard value (prim. keys start with 1, not with 0) is no option,
so I need another solution to fix this.
Does anyone have an idea?
Thanks,
Peter