SV: [SMARTY] Using PHP variables in smarty control structures

From: Date: Wed, 02 Oct 2002 07:56:43 +0000
Subject: SV: [SMARTY] Using PHP variables in smarty control structures
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6069@lists.php.net to get a copy of this message
Try something like: In the php file : <?php if ($lang="en"){ $smarty->assign("lang","en"); } ?> then in the template write {config_load file="index.cfg" section=$lang} Paolo > -----Oprindelig meddelelse----- > Fra: Brodie Thiesfield [mailto:bt@jellycan.com] > Sendt: 2. oktober 2002 04:42 > Til: smarty-general@lists.php.net > Emne: [SMARTY] Using PHP variables in smarty control structures > > > Hi, > > I'm trying to use a PHP variable to control the section for the > include_config directive within the template file. I have tried the > following methods so far... > > {* (1) language dependent config file *} > <?php > if ( $lang == "en" ) > print '{config_load file="index.cfg" section="en"}'; > if ( $lang == "ja" ) > print '{config_load file="index.cfg" section="ja"}'; > ?> > > {* (2) language dependent config file *} > {if $lang eq "en"} > {config_load file="index.cfg" section="en"} > {elseif $lang eq "ja"} > {config_load file="index.cfg" section="ja"} > {else} > {config_load file="index.cfg" section="en"} > {/if} > > {* (3) language dependent config file *} > {config_load file="index.cfg" section="$lang"} > > {* (4) language dependent config file *} > {config_load file="index.cfg" section="{$lang}"} > > > But none of these ways have worked. Can anyone help me with this? It > seems like it should be simple - have a variable determine which section > is loaded from the config file.... > > Brodie. > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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