Bug, or bad coding?

From: Date: Mon, 12 Nov 2001 02:03:55 +0000
Subject: Bug, or bad coding?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1901@lists.php.net to get a copy of this message
I've been working with Smarty a ton lately and I've grown to love it. The problem I'm having, however, is that a nested {section} is looping 3 times while the count($array) returns 4. So, I get the first 3 elements printed properly on the first loop, then a blank at the very end. Here is the offending template: {section name=rows loop=$Dates} <p><font size="+1">{$Dates[rows]}</font></p> {section name=row loop=$Posts} <table> <tr> <td bgcolor="#CCCCCC">{$Posts[rows][row].newsHeadline}</td> <td>{$Posts[rows][row].userID}</td> </tr> </table> <p>{$Posts[rows][row].newsText}</p> {/section} {/section} Here is the code on my assigns: $tpl->assign("Dates", $displayDates); $tpl->assign("Posts", $displayPosts); And a count($displayDates) returns 3 (and it's looping 3 times), and here are the counts of the following: count($displayPosts[0]) = 4 count($displayPosts[1]) = 3 count($displayPosts[2]) = 2 The problem is, it's looping through "Posts" ($displayPosts[0]) 3 times instead of 4. Then, it's printing a blank "section" at the very bottom (the HTML printing but no values). Any help would be greatly appreciated. If you need more of the code, I'd be happy to provide it. Brian ======================== The Massassi Temple http://www.massassi.net/ "How should I know if it works? That's what beta testers are for. I only coded it." - Linus Torvalds

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