Re: [SMARTY-DEV] {counter} bug and patch
| From: | Bharat Mediratta | Date: | Tue, 03 Jun 2003 08:04:37 +0000 |
| Subject: | Re: [SMARTY-DEV] {counter} bug and patch | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1530@lists.php.net to get a copy of this message | ||
From: "messju mohr" <messju@lammfellpuschen.de>
...
> this should be fixed in cvs now. please test.
>
> On Fri, May 30, 2003 at 10:31:48PM -0700, Bharat Mediratta wrote:
> >
> > Hi, all. I just updated from 2.5.0 to HEAD today to see how
> > the latest stuff is working and noticed something odd with
> > {counter}.
Ok, this fixes the off-by-one error. However, now the new code
does not return the counter number. Ie, my test code returns:
child1:
child2:
child3:
instead of:
child1: 0
child2: 1
child3: 2
which is what HEAD used to do before your fix (and is what the
docs claim as the correct behaviour).
-Bharat
------------
My test:
/* PHP */
$smarty = new Smarty();
$children = array();
for ($i = 1; $i < 10; $i++) {
$children[] = 'child' . $i;
}
$smarty->assign('children', $children);
$smarty->display('test.tpl');
{* Smarty *}
{counter assign=index start=0 print=false}
{$children[$index]}: {counter} <br>
{$children[$index]}: {counter} <br>
{$children[$index]}: {counter} <br>