Re: foreach on iterator

Sean Coates <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
Please read the archives.
http://news.php.net/php.smarty.dev/2608

S

Robin Ericsson wrote:
> Hi,
> 
> I sent this to smarty-general, but smarty-dev might be a better place.
> 
> """
> I have a class which it using SPL and implements Iterator. It works when 
> I do it manually
> 
> foreach($iterator as $key) {
> }
> 
> however, using smarty {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?
> """
> 

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.