0

I am using smarty 3.1.12 for templating, however in my php files i am tryig to access my smarty variables. All my research has returned answers only for previous versions of smarty.

  • The smarty documentation is good place to start looking, http://www.smarty.net/docs/en/api.get.template.vars.tpl – hank Jan 28 '13 at 07:49

3 Answers3

0

use below code

$myVars = $this->get_template_vars(); 
$this->assign('myVars',$myVars); 
{foreach from=$myVars key=k item=i} 
{$k}: {$i}
{/foreach} 
Ripa Saha
  • 2,532
  • 6
  • 27
  • 51
0

in php file:

$smarty->assign('myVars',$myVars);

in tpl file:

{$myVars}

or:

{foreach $myVars as $k=>$var}
{$var}
{/foreach}
Catalin Sterian
  • 96
  • 1
  • 10
0
$myVar = $SMARTY->getTemplateVars('myVar');

Use this method for your smarty version 3.1.12

Nijesh Hirpara
  • 1,096
  • 1
  • 12
  • 17