Re: [SMARTY] Variable variables in templates?
| From: | philippe dot morange at ca-indosuez dot com | Date: | Mon, 24 Mar 2003 12:26:11 +0000 |
| Subject: | Re: [SMARTY] Variable variables in templates? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-8859@lists.php.net to get a copy of this message | ||
>> In my template I need to use the different lists like this:
>> {foreach from=$list_$i item=list_item}
>> <option label="{$list_item.name} ({$list_item.contract_name})"
>> value="{$list_item.id}">
{$list_item.name} ({$list_item.contract_name})</option>
>> {/foreach}
>>
>> Where $list_$i refers to $list_1, $list_2, $list_3, etc...
>> I don't know how many lists I will have, so I have to use variable variables...
>>
>> What could I do to make this work?
>
> use a 2-dimensional-array "list" for sth. like that and do
> {foreach from=$list.$i item=list_item}...
Thanks a lot.
Seems like I forgot the golden rule once again: "Keep It Simple" :-)