Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Access a Smarty variable from plugin

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
implico
Smarty n00b


Joined: 03 Dec 2014
Posts: 2

PostPosted: Wed Dec 03, 2014 3:08 am    Post subject: Access a Smarty variable from plugin Reply with quote

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
View user's profile Send private message
n0xor
Smarty Rookie


Joined: 04 Dec 2014
Posts: 6

PostPosted: Thu Dec 04, 2014 5:30 pm    Post subject: Reply with quote

Try that

Code:
 $template->smarty->getTemplateVars();

http://www.smarty.net/docs/en/api.get.template.vars.tpl


Or did I missunderstood u? Provide some example[/code][/quote]
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Dec 05, 2014 1:01 am    Post subject: Reply with quote

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
View user's profile Send private message
implico
Smarty n00b


Joined: 03 Dec 2014
Posts: 2

PostPosted: Sun Dec 07, 2014 9:56 pm    Post subject: Reply with quote

My words:
Quote:
Maybe stupid


...were true:) thank you
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP