RE: [SMARTY] Using smarty variables inside {php} {/php} blocks
| From: | Ferdinand Beyer | Date: | Thu, 05 Sep 2002 18:21:57 +0000 |
| Subject: | RE: [SMARTY] Using smarty variables inside {php} {/php} blocks | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5943@lists.php.net to get a copy of this message | ||
On 5 Sep 2002 at 9:24, Gary Loescher wrote:
> >
> >Finally, this is the CLEANEST way:
> >
> >{assign var="x" value="Hello World!"}
> >
> >{php}
> >extract($this->_tpl_vars);
> >
> >echo $x;
> >{/php}
> >
> >Outputs: "Hello World!";
> >
> >If you want to use template vars inside {php} or
> >{include_php} tags,
> >use extract($this->_tpl_vars) to extract the vars from
> >the Smarty
> >scope to the method scope!
> >
> >--
> >Ferdinand Beyer
> ><fbeyer@clickhand.de>
>
> What if you don't want to bring all of the template
> vars into the current scope? For instance, on one of
> my projects I have over 300 template vars. I try to
> avoid mingling Smarty/PHP scopes anyway, but if I
> were going to I'd only want to grab one or two vars.
Smarty will extract those vars any way - I don't think this is a
performance issue. Have you done some benchmarks?
Nevertheless, I hope you agree with me when I say you should
always access the $_tpl_vars array in order to get template vars
inside {php} and {include_php}.
--
Ferdinand Beyer
<fbeyer@clickhand.de>