Possible Bug with Custom User Functions in loops

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
jgoforth
New Member
New Member
Posts: 3
Joined: Sun Aug 05, 2012 6:18 am

Possible Bug with Custom User Functions in loops

Post by jgoforth »

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

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');
?>
test.tpl

Code: Select all

<ul>
{foreach from=$records item=entry}
<li>{tester item=$entry->date} - {$entry->date|cms_date_format}</li>
{/foreach}
</ul>
tester user tag

Code: Select all

echo $params['item'];
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.
Post Reply

Return to “The Lounge”