RE: [SMARTY] Re: Embedding vars
| From: | Marshall Sorenson | Date: | Tue, 28 Oct 2003 13:22:31 +0000 |
| Subject: | RE: [SMARTY] Re: Embedding vars | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10452@lists.php.net to get a copy of this message | ||
Luca,
This syntax is a waste...
$smarty->assign("myvar", $GET["foo"]);
You can just use {$smarty.get.foo}
That being said, I would not recommend using $_GET variables without first
making them "safe" by passing each value through a function like
escapeshellcmd or similar.
-Marshall
____________________________________
"If at first the idea is not absurd,
then there is no hope for it."
- Albert Einstein
> -----Original Message-----
> From: Luca Borrione [mailto:spatuss@hotpop.com]
> Sent: Tuesday, October 28, 2003 6:14 AM
> To: Robert Sedlacek
> Cc: smarty-general@lists.php.net
> Subject: [SMARTY] Re: Embedding vars
>
>
> Robert Sedlacek wrote:
>
> > On Thu, 23 Oct 2003 18:19:49 +0200, Luca Borrione wrote:
> >
> >>$smarty->assign("myvar", "var1");
> >
> >
> > Try
> >
> > $smarty->assign('myvar', $smarty->get_config_var('var1'));
> >
> >
> > Robert
>
>
> 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 General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>