RE: Bug, or bad coding?

From: Date: Mon, 12 Nov 2001 05:32:48 +0000
Subject: RE: Bug, or bad coding?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1902@lists.php.net to get a copy of this message
You probably need this instead {section name=row loop=$Posts[rows]} Cheers > -----Original Message----- > From: Brian E. Lozier [mailto:brian@massassi.net] > Sent: Monday, 12 November 2001 12:04 PM > To: smarty@lists.ispi.net > Subject: [smarty] Bug, or bad coding? > > > 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

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