Re: [SMARTY] dynamic var
| From: | messju mohr | Date: | Tue, 19 Aug 2003 11:09:26 +0000 |
| Subject: | Re: [SMARTY] dynamic var | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10094@lists.php.net to get a copy of this message | ||
On Tue, Aug 19, 2003 at 01:01:41PM +0200, Martin Kloss wrote:
> hi there,
>
> I know this has been discussed lots of times already, but
> I can't seem to figure out how to do the following (simplified):
>
> I have a 2-dim array $contents which looks like this:
> $contents = array(array('content_de' = 'foo', 'conten_en' =
> 'bar'...)...));
>
> Now I want to loop through the array to get the content
> depending on the user's language setting:
>
> {foreach from=$contents item="c"}
> {$c.content_$language}
> {/foreach}
to my knowledge there is no direct syntax for this, you have to assign
an intermediate value:
{foreach from=$contents item="c"}
{assign var=content_language value="content_$language"}{$c.$content_language}
{/foreach}
> But that doesn't work. Now how do you get the field name
> dynamically assigned? I tried a couple of combinations with
> quotes, but it wouldn't work.
>
> Martin.
>
> P.S. My previous problem has been solved. The php.ini on
> the new server had safe_mode turned on, so it wouldn't allow
> me to get anywhere below the web root.
>
>
> Martin Kloss
> martin.kloss@triquart.de
> Technische Direktion
>
> ************************
> Triquart Neue Medien
> Bellealliancestr.17
> 20259 Hamburg
> Germany
> Tel.+49 (40)432 923-0
> Fax +49 (40)432 923-23
> www.triquart.de
> www.triquart-humor.de
> *************************
>
> "Lingo objektorientiert"
> Das Buch zum Autor jetzt bestellen unter:
> http://www.amazon.de/exec/obidos/ASIN/3898422194/lingmmugd
>
>