Re: New looping method proposal

From: Date: Mon, 19 Nov 2001 18:13:05 +0000
Subject: Re: New looping method proposal
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1969@lists.php.net to get a copy of this message
On Mon, Nov 19, 2001 at 12:03:50PM -0600, Andrei Zmievski wrote: > On Mon, 19 Nov 2001, Ivo Jansch wrote: > > Mind you, my proposal is also usable for nested sections! (Andreas' > > remark was not correct) > > > > Consider this: > > > > {foreach $projects as $project} > > > > {$project.title} > > <br> Here are the contactpersons for this project: > > <ul> > > {foreach $project.contactpersons as $contact} > > <li>{$contact.name} > > {/for} > > </ul> > > {/for} > > > > Is this not far more easy then the current method of nesting sections? > > > > The only thing not possible in my approach is Monte's remark about > > indices. But that was covered by my second proposal: > > > > {foreach $projects as $index => $project} > > <br> something from another array: {$prices[$indes]} > > {/for} > > I am willing to entertain the idea of this construct, because it will > solve the problem of looping through non-sequential or associative > arrays. However, I do not think that I want to use the same syntax as > PHP does. Can we come up with something better? {loop [over] $array as $index => $value} {/loop} ??

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