Possible Bug with Custom User Functions in loops
Posted: Wed Aug 08, 2012 5:04 am
I believe that I have found a bug in how custom user tags are handled inside of loops. In particular, this is an issue when the tag takes parameters and does something to them.
action.test.php
test.tpl
tester user tag
This results in the following:
* 2000-12-08 - Mar 24, 2012
* 2000-12-08 - Feb 15, 2005
* 2000-12-08 - Dec 8, 2000
While the predefined tag is correctly working on each piece of information in the loop, it would seem the user defined tag isn't evaluated until the end and thus each iteration of the loop uses the data from the last loop.
action.test.php
Code: Select all
<?php
$records = array();
$rec1 = new stdClass();
$rec1->date = '2012-03-24';
array_push($records, $rec1);
$rec2 = new stdClass();
$rec2->date = '2005-02-15';
array_push($records, $rec2);
$rec3 = new stdClass();
$rec3->date = '2000-12-08';
array_push($records, $rec3);
$this->smarty->assign('records',$records);
echo $this->ProcessTemplate('test.tpl');
?>
Code: Select all
<ul>
{foreach from=$records item=entry}
<li>{tester item=$entry->date} - {$entry->date|cms_date_format}</li>
{/foreach}
</ul>
Code: Select all
echo $params['item'];
* 2000-12-08 - Mar 24, 2012
* 2000-12-08 - Feb 15, 2005
* 2000-12-08 - Dec 8, 2000
While the predefined tag is correctly working on each piece of information in the loop, it would seem the user defined tag isn't evaluated until the end and thus each iteration of the loop uses the data from the last loop.