[英]Why is it possibile to access variables in smarty templates with Prestashop?
[英]Access smarty variables: smarty 3.1.12
我正在使用smarty 3.1.12進行模板制作,但是在我的php文件中,我正在嘗試訪問我的smarty變量。 我所有的研究都只為以前版本的smarty返回了答案。
使用以下代碼
$myVars = $this->get_template_vars();
$this->assign('myVars',$myVars);
{foreach from=$myVars key=k item=i}
{$k}: {$i}
{/foreach}
在php文件中:
$smarty->assign('myVars',$myVars);
在tpl文件中:
{$myVars}
要么:
{foreach $myVars as $k=>$var}
{$var}
{/foreach}
$myVar = $SMARTY->getTemplateVars('myVar');
為您的smarty版本3.1.12使用此方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.