RE: [SMARTY] Using smarty variables inside {php} {/php} blocks
| From: | Gary Loescher | Date: | Wed, 04 Sep 2002 21:16:09 +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-5930@lists.php.net to get a copy of this message | ||
Here's a bit of a cleaner way to do it...someone
posted this awhile back (can't remember who, sorry :)
function GetTplVar($name)
{
return isset($this->_tpl_vars[$name]) ?
$this->_tpl_vars[$name] : NULL;
}
Just add this to your smarty subclass.
Gary
>-----Original Message-----
>From: Ben Godfrey [mailto:ben@hypothetical.co.uk]
>Sent: Wednesday, September 04, 2002 4:01 PM
>To: smarty-general@lists.php.net
>Subject: Re: [SMARTY] Using smarty variables inside
>{php} {/php} blocks
>
>
>
>I don't have time to test it right now, but I would
>expect the same
>code:
>
> $this->_tpl_vars["bar"];
>
>to work with {include_php} as well. That is assuming
>that {include_php}
>is just a wrapper for PHP's include.
>
>Ben
>
>
>On Wednesday, Sep 4, 2002, at 21:50 Europe/London,
>Jorge Restrepo -
>WebTeam wrote:
>
>> I've got a similar question, but about using smarty
>variables in
>> include_php
>> files.\
>>
>>
>>
>>
>>
>>> -----Original Message-----
>>> From: Jaime Ashander [mailto:JaimeA@dis-corp.com]
>>> Sent: Wednesday, September 04, 2002 3:32 PM
>>> To: smarty-general@lists.php.net
>>> Subject: [SMARTY] Using smarty variables inside
>{php} {/php} blocks
>>>
>>>
>>> So, I think I may have had this working at one
>point, but now
>>> whenever I
>>> try it things go wrong.
>>>
>>> Example:
>>>
>>> Foo.php:
>>> ------------------
>>> <?php
>>> #my smarty is an innocent subclass that simply sets
>directories
>>> require_once 'my_smarty.inc';
>>>
>>> $smarty= new My_Smarty();
>>> $smarty->assign('bar', 'I want to be displayed');
>>> $smarty->display('foo.tpl');
>>> ?>
>>>
>>> Foo.tpl:
>>> ------------------
>>>
>>> <html>
>>> <body>
>>> <!-- random code-->
>>> Displayed via smarty:
>>> {$bar}
>>>
>>> <br>
>>>
>>> Displayed via php:
>>> {php}
>>> $bar
>>> {$bar}
>>> {/php}
>>> </body>
>>> </html>
>>>
>>
>>
>> --
>> Smarty General Mailing List (http://smarty.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>(q) Ben Godfrey?
>(a) Developer and Designer,
> See http://aftnn.org/ for details
>
>
>--
>Smarty General Mailing List (http://smarty.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>