RE: [SMARTY] Optional Sections

From: Date: Tue, 24 Feb 2004 15:33:02 +0000
Subject: RE: [SMARTY] Optional Sections
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11017@lists.php.net to get a copy of this message
I've had the best luck assigning an associative array to a Smarty variable. If you make it multi-dimensional, you can nest Sections. Check out Example 7-18. nested sections, at http://smarty.php.net/manual/en/language.function.section.php Geoffrey D. Hoffman Lead Web Developer Arizona Interactive Media Group mailto:ghoffman@aztrib.com > -----Original Message----- > From: Jake Stride [mailto:jas@dcs.warwick.ac.uk] > Sent: Tuesday, February 24, 2004 2:00 AM > To: smarty-general@lists.php.net > Subject: [SMARTY] Optional Sections > > > Now I have the following in Smarty that I am using as a test: > > {foreach key=key item=item from=$menu_options} > <tr> > <td class="submenu">{$item}</td> > </tr> > {/foreach} > > However whenever I call assign() I only ever get the last > call to it showing > in the template. Is there a way to do this in smarty? I > ideally want to > scale it too so that I could do the following > > <!-- first section --> > <tr> > <td colspan="2">{$someTitle}</td> > </tr> > <!-- second section --> > <tr> > <td>{$key}</td> > <td>{$value}</td> > </tr> > <!-- end second section --> > <!-- end first section --> > > In this example I would like to be able to put several > "second sections" in > the template with the "first section" as a header row. But I > would like to > be able to do it more than once so: > > <tr> > <td colspan="2">Men</td> > </tr> > <tr> > <td>Joe</td> > <td>Bloggs1</td> > </tr> > <tr> > <td>Joe</td> > <td>Bloggs2</td> > </tr> > <tr> > <td colspan="2">Women</td> > </tr> > <tr> > <td>Jane</td> > <td>Bloggs1</td> > </tr> > <tr> > <td>Jane</td> > <td>Bloggs2</td> > </tr> > > Thanks for any help I may receive. > > Jake

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