Re: loop

From: Date: Wed, 28 Mar 2001 17:03:02 +0000
Subject: Re: loop
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-482@lists.php.net to get a copy of this message
On Wed, 28 Mar 2001, Ivo Jansch wrote: > Ok, forget this. If you do this, then a simple loop like: > > > $smarty->assign("list",Array(Array("name"=>"sjappie"),Array(Array("name"=>"flappie"))); > > {section name=mysection loop=$ylist} > <br>Url: {$mysection/list.name} > {/section} > > won't work anymore. :) > The reason is an ambiguity in the template language. Yes. > If we solve this, we could define *ANY* datastructure that you could > possibly think of. > > Solutions I have been thinking about: > - {section name="sec1" loop=$list.names}, where $list.names is not just > the array on which you loop, but > also the 'base' for your data. ($sec1/url) would then give the "url" > item from the $list.names array. > Additional pro: nested sections can loop on items from the same assign > statement, which would allow you > to build a complete tree in one assign statement. But then you are restricting yourself to only looping through one array. Many times you need to loop through several arrays at once. > - Change the syntax a bit, perhaps {$sec1/@items.url} or something like > that.. Coming up with good syntax is where the crux of the problem is. -Andrei * The future has arrived, it's just not evenly distributed. -W. Gibson *

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