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

Help using SMARTY value in PHP script

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
sarahfoxnz
Smarty Regular


Joined: 11 Apr 2010
Posts: 76

PostPosted: Tue May 19, 2015 10:33 am    Post subject: Help using SMARTY value in PHP script Reply with quote

Hello. I've got a slight problem with including a "smarty" variable into a PHP
script.



[code]{php}
global $group;
require_once ("/home/users/xxx/xxx/usr/functions/Global.class.php");
header("Title events- ".$group[name],"Title Events ".$group

[name],1,"/css/basic.css");
echo "HELLO $group";
{/php}
[/code]

When i view HELLO $group, in the above code, I get the result of my PHP script where i used $group.

However, when I use {$group} in my snarty code below the above, I get the "smarty" value of $group.


the problem is, I want to use $group.name (from smarty) in the above PHP coding.

i've googled, but cannot find a situation similar to this.

I'll appreciate any assistance.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed May 20, 2015 4:06 am    Post subject: Reply with quote

You can get the variable with
Code:
$group = $_smarty_tpl->getTemplateVars('group');

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

Please note that including PHP code in templates is deprecated.
You may consider to write a function plugin instead.
See http://www.smarty.net/docs/en/plugins.tpl
See http://www.smarty.net/docs/en/plugins.functions.tpl
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 -> Tips and Tricks 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