Re: Embedding vars
| From: | Luca Borrione | Date: | Tue, 28 Oct 2003 11:14:06 +0000 |
| Subject: | Re: Embedding vars | ||
| References: | 1 2 | Groups: | php.smarty.general php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10448@lists.php.net to get a copy of this message | ||
Robert Sedlacek wrote:
On Thu, 23 Oct 2003 18:19:49 +0200, Luca Borrione wrote:Hi Robert, thank you for your answer. You're right: this works, but this is a little bit longer than the tag syntax I was looking for. Following your suggestion I have to write: {config_load file="smarty.conf" section="mysection"} {php} $cvars = $this->get_config_vars(); $this->assign("myvar", $cvars["var1"]) {/php} {$myvar} or, as you prefer, {config_load file="smarty.conf" section="mysection"} {php} $this->assign("myvar", $smarty->get_config_var("var1")) {/php} {$myvar} but what I was looking for was a shorter template syntax. having a config file where I specify: [mysection] var1 = value1 var2 = value2 I want to assign a php variable, for example through a query part: /index.php?foo=var1 into index.php I want to call Smarty: $smarty = new Smarty; $smarty->assign("myvar", $GET["foo"]); $smarty->display(template.tpl"); into template.tpl I would like to write quickly something like: {config_load file="smarty.conf" section="mysection"} {#$myvar#} in order to print *value1*, and if I call the page using /index.php?foo=var2 I will print *value2* Your suggestion will work, but, I repeat, I'm looking for a shorter syntax. Maybe if there isn't any, it could be an idea to add it into future releases.. or am I the only one who likes short syntax? Cheers Luca$smarty->assign("myvar", "var1");Try $smarty->assign('myvar', $smarty->get_config_var('var1')); Robert