foreach on Iterator
| From: | Robin Ericsson | Date: | Fri, 18 Mar 2005 13:32:12 +0000 |
| Subject: | foreach on Iterator | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-12341@lists.php.net to get a copy of this message | ||
Hi,
I have a class which it using SPL and implements Iterator. It works when I do it manually
foreach($iterator as $key) {
}
however, using {foreach from=$iterator item=key) generates the following code:
<?php if (count($_from = (array)$this->_tpl_vars['revisionIterator'])):
foreach ($_from as $this->_tpl_vars['revision']):endforeach; endif; unset($_from); ?> You see the difference that Smarty really casts the object into an array and therefore break my class. What can I do about it? -- Robin Ericsson http://robin.vill.ha.kuddkrig.nu/