Re: [SMARTY] Optional Sections
| From: | Jake Stride | Date: | Tue, 24 Feb 2004 17:05:35 +0000 |
| Subject: | Re: [SMARTY] Optional Sections | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11018@lists.php.net to get a copy of this message | ||
No, I have read this already. Perhaps I am not explaining it correctly.
Is it possible to have a section in Smarty that you can fill out with an
array, 'Parse', and then start over again. What I can do in PEAR is have a
generic template for a form. So have one 'Block' (as they are in pear) which
is for a text input, another for a select etc. Then when I want to make a
form I can choose each item as many times as I want, but out of order.
I have enclosed an example template that I use in pear. With this I can
assign to one block, parse, assign to another block and then go back to the
first block if I want to, or a completely different block if that is what I
need.
Thanks
Jake
On 24/2/04 15:33, "Hoffman, Geoffrey" <ghoffman@aztrib.com> wrote:
> 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