RE: [SMARTY] Using smarty variables inside {php} {/php} blocks
| From: | Gary Loescher | Date: | Thu, 05 Sep 2002 14:24:35 +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-5940@lists.php.net to get a copy of this message | ||
>
>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.
Gary