2010-02-12 134 views
1

我正在处理网站是一团糟,需要找出smarty呈现的模板文件。获取模板名称 - Smarty

我可以通过调用smarty模板对象获取当前模板文件吗?

例如

echo $tplObj->getTemplate(); // echos "shop/templates/cart.tpl" 

回答

12

从DOC:

{$smarty.template} 

返回当前模板的名称正在处理中。以下示例显示了container.tpl和两者中包含的{$ smarty.template}中包含的banner.tpl。

<b>Main container is {$smarty.template}</b> 
{include file='banner.tpl'} 

将输出

<b>Main page is container.tpl</b> 
banner.tpl