Re: [SMARTY] while loop in smarty like ...

From: Date: Tue, 19 Aug 2003 19:06:17 +0000
Subject: Re: [SMARTY] while loop in smarty like ...
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10099@lists.php.net to get a copy of this message
On Tue, Aug 19, 2003 at 08:16:34PM +0200, Kai-Uwe Beyer wrote: > messju mohr wrote: > > > with smarty-2.6.0 you can make your block-function-plugins behave like > > iterators. see: > > > > http://smarty.php.net/manual/en/plugins.block.functions.php (i just > > noticed the fourth parameter "&$repeat" is missing in the > > function-prototype on that page, i'll update that soon). > > > Thank you. my problem now is: > > "Note that the template block will have already been processed by > Smarty, so all you will receive is the template output, not the template > source." > > Where comes from my iterator object. Get it from the template or ther > parms parameter? > I think i didn't understand the principle of block functions. > > In this template block i want generate a link list to movies like: > {$movieIterator->next()->getLink()} > The movie Iterators funcrion next() returns an Movie Object. > > Here my idea for the block function: > > function smarty_block_movielinklist($params, $content, &$smarty) > { > $iterator = parms['iterator']; > if ($content) { > do while($repeat = $iterator->next()){ > echo $iterator->next()->getlink(); > } > } > } what about this: [in your .php] $links = array(); while($repeat = $iterator->next()) { $links[] = $iterator->next()->getlink(); } $smarty->assign('links', $links); [and in the .tpl] {foreach from=$links item=link} {$link} {/foreach} i think you don't need a custom block here necessarily. > I didn't understand, which value the $contet has. > > Thank you > > Greetings > > Kai > > P.S. Sorry for my bad english. I hope you understand what my problem is. > In german: Vielleicht kann man es ja auch in deutsch per Mail machen > > > > > you can test this in 2.6.0-RC1. if your projects timeframe isn't to > > short a stable release containing this ability may be out when you > > need it for production. > > > Thats no problem, because my hompage still have development status

« previous php.smarty.general (#10099) next »