Re: loop

From: Date: Tue, 27 Mar 2001 20:12:50 +0000
Subject: Re: loop
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-461@lists.php.net to get a copy of this message
Well, Andrei's answer could be read as: because Smarty is programmed this way, it's impossible to do what you want having the array in question. Ok, but my practice shows: if the data structure doesn't fit to Smarty, change the data structure to the one Smarty likes :-) Your array: Array("names"=>Array("sjappie","flappie","happie")); can be restructurized to the following array: array(array("names"=>"sjappie"),array("names"=>"flappie"),array("names"=>"ha ppie")); which works with your template with one modification: loop=$list.names should become loop=$list Of course, this is not the remedy to Smarty problem you found. But I learnt for 2 months Smarty is powerful and can be used even in quite a big projects if you use its most sophisticated features. Maciek > -----Original Message----- > From: Andrei Zmievski [mailto:andrei@ispi.net] > Sent: Tuesday, March 27, 2001 4:07 PM > To: Ivo Jansch > Cc: smarty@lists.ispi.net > Subject: [smarty] Re: loop > > > On Tue, 27 Mar 2001, Ivo Jansch wrote: > > Hi, > > > > why doesn't this work: > > > > index.php: > > > > > > $smarty->assign("list",Array("names"=>Array("sjappie","flappie","h appie"))); > > > > index.tpl: > > > > <ul> > > {section name="sec1" loop=$list.names} > > <li>{$sec1/list.names} > > {/section} > > </ul> > > > > I can see the bullets, but no names.. > > Because Smarty first indexes by section iteration and then by string > keys.. > > -Andrei > > A room without books is like a body without a soul. > -- Marcus Tullius Cicero (106-43 B.C.) > > --- > You are currently subscribed to smarty as: muhlig@us.edu.pl > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ >

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