|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
implico Smarty n00b
Joined: 03 Dec 2014 Posts: 2
|
Posted: Wed Dec 03, 2014 3:08 am Post subject: Access a Smarty variable from plugin |
|
|
Maybe stupid, but is it possible to access a Smarty assigned variable from a plugin (namely, a normal and block function)? The documentation demonstrates only how to assign a value, Google not helping.
Until now, I was managing by using static properties of a class (they are global).
I need it for some specific helper functions, like {cfg f=configName1} instead of {$config->get('configName1')|escape}. Now I have to do: \App::getInstance()->getConfig()->get('...') - I had to make the getInstance method just for this purpose. It would be nice to get it like this: $template->get('config')->get('...')
Thanks |
|
Back to top |
|
n0xor Smarty Rookie
Joined: 04 Dec 2014 Posts: 6
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Dec 05, 2014 1:01 am Post subject: |
|
|
A small note
n0xor wrote: | Code:
$template->smarty->getTemplateVars();
|
If you call $template->smarty->getTemplateVars(); you will see only variables which have been assigned to the Smarty object, but not variables which might have been assigned inside the templates
.
To get access to all variables of the current template scope use
Code: |
$template->getTemplateVars();
|
|
|
Back to top |
|
implico Smarty n00b
Joined: 03 Dec 2014 Posts: 2
|
Posted: Sun Dec 07, 2014 9:56 pm Post subject: |
|
|
My words:
...were true:) thank you |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|