Reputation: 8762
If have used {debug} to see what data i can access in a page. Now the stuff i need sit's in {$GLOBALS} like
current_user => Array (17)
id => 3759
user_name => bla
email => [email protected]
group => Array (2)
id => users
caption => Users
But how to i get the data i need to show on my page? Like the e-mail adress?
Upvotes: 4
Views: 5098
Reputation: 66465
If you've only access to the template file, you could assign $GLOBALS
to a smarty var $globals
like this:
{php}$this->assign('globals', $GLOBALS);{/php}
{$globals.somevar}
$this
refers to the active Smarty object.
A better way to implement this, when having access to the PHP script, would be:
<?php
$somevar = 'this is a test';
$tpl = new Smarty;
$tpl->assign('globals', $GLOBALS);
$tpl->display('example.tpl');
?>
Template file:
{$globals.somevar}
Optionally use a filter like:
{$globals.somevar|escape:html}
Upvotes: 3
Reputation: 1178
I guess this may work:
{php}
echo $GLOBALS['current_user']['email'];
{/php}
(This is not the best way. You will need to make sure that the data is escaped before output, so you can use htmlentities() or better to assign the data in your code, see: http://www.smarty.net/manual/en/api.assign.php)
Upvotes: 0