{section} with array that doesnt start with index 0

From: Date: Sun, 18 Aug 2002 20:19:32 +0000
Subject: {section} with array that doesnt start with index 0
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5739@lists.php.net to get a copy of this message
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

« previous php.smarty.general (#5739) next »