【问题标题】:Get Template Name - Smarty获取模板名称 - Smarty
【发布时间】:2010-02-12 05:29:53
【问题描述】:

我正在处理的网站很乱,需要找出 smarty 正在渲染的模板文件。

我可以调用 smarty 模板对象上的方法来获取当前模板文件吗?

例如

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

【问题讨论】:

    标签: php templates smarty


    【解决方案1】:

    来自文档:

    {$smarty.template}
    

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

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

    会输出

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

    【讨论】:

      【解决方案2】:

      也许{debug} 标签及其关联的Debugging console 可以提供帮助,在这里?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-04
        • 1970-01-01
        • 2011-03-10
        • 1970-01-01
        相关资源
        最近更新 更多