[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-general
Subject:    Re: [SMARTY] Concatenated string as array index
From:       David =?ISO-8859-1?Q?F=F6rster?= <david () dfoerster ! de>
Date:       2004-05-26 15:38:51
Message-ID: 20040526183851.3b7e7a36.david () dfoerster ! de
[Download RAW message or body]


Hello,

I don't think that's possible. I'd rather recommend to change the array slightly:

$entry = array(
	"de" => array(
		"text" => "Deutscher text",
		"head" => "Deutsche Ueberschrift",
	)
	"en" => array(
		"text" => "english text",
		"head" => "english headline",
	)
);

That'd be easier to handle.

- david 

On Wed, 26 May 2004 17:21:48 +0200
Gabriel Birke <birke@kontor4.de> wrote:

> Hello!
> 
> I've got the following array:
> $entry = array(
> 	"text_de" => "Deutscher text",
> 	"text_en" => "english text"
> 	"head_de" => "Deutsche Ueberschrift",
> 	"head_en" => "english headline"
> );
> 
> The variable $l stores the locale abbreviation ("en" or "de")
> 
> Something like
> echo $entry["head_".$l]."<br>".$entry["text_".$l];
> is very elegant. Is a statement like this possible in Smarty?
> 
> Or do i have to assign the correct field names from php like this:
> 
> $smarty->assign("text_local", "text_".$l);
> $smarty->assign("head_local", "head_".$l);
> 
> In the template:
> {$entry.$head_local}<br />{$entry.$text.local}
> 
> With best regards
> 
> Gabriel Birke
> 
> -- 
> KONTOR4_Neue Medien
> Plathnerstraße 5
> 30175 Hannover
> Fax: +49 51184 48 98 99
> mailto:birke@kontor4.de
> http://www.kontor4.de
> -- 
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic