Re: [SMARTY] Loop a section of an array

From: Date: Mon, 03 Jun 2002 11:17:47 +0000
Subject: Re: [SMARTY] Loop a section of an array
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4509@lists.php.net to get a copy of this message
Shouldn't it be (untested code): {section name=b loop=$box} <b>{$box[b].title}</b> {section name=i loop=$box[b].data} <li>{$box[b].data[i].article_url}</li> {/section} {/section} Jason ----- Original Message ----- From: "Peter Bowyer" <peter@mapledesign.co.uk> To: <smarty-general@lists.php.net> Sent: Monday, June 03, 2002 3:12 AM Subject: [SMARTY] Loop a section of an array > Hi, > > If I hav ethe folowing structure: > $box = Array > ( > [title] => Your articles > [empty] => You do not have any articles. Would you like to <a > href="/articles/add_article.php">write one</a>? > [data] => Array > ( > [0] => Array > ( > [article_url] => island_railways_north_of_europe > [article_title] => Island Railways north of Europe > ) > > [1] => Array > ( > [article_url] => a_trip_on_the_launceston_steam_railway > [article_title] => A trip on the Launceston Steam Railway > ) > > ) > > ) > > How do I loop the [data] section? I've tried the following that won't work: > <ul> > {* The following row needs to be looped *} > {section loop=$box.data name=i} > <li><a > href="/articles/{$box.data[i].article_url}">{$box[i].article_title}</a></li> > {sectionelse} > <li>{$box.empty}</li> > {/section} > </ul> > > Thanks > Peter > > --oOo-- > Narrow Gauge on the web - photos, directory and forums! > http://www.narrow-gauge.co.uk > --oOo-- > Glenbranter - Scottish narrow gauge in 009 > http://glenbranter.narrow-gauge.co.uk > --oOo-- > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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