【问题标题】:Fetch Smarty template name within php在 php 中获取 Smarty 模板名称
【发布时间】:2011-08-03 13:58:17
【问题描述】:

我已经注册了一个负责翻译的块函数。

$smarty->register_block("translate", "do_translation");

函数 do_translation ($params, $content, &$smarty, &$repeat) { ... }

我可以通过使用 PHP 中的 $smarty 对象以某种方式确定是哪个模板文件导致了函数调用吗? 或者我可以在 php 中获取当前呈现的模板吗?

【问题讨论】:

    标签: php smarty


    【解决方案1】:

    第三个参数是 Smarty 对象。我不确定,但你可以试试

    echo $smarty->_current_file; //Smarty 2
    

    echo $smarty->template; //Smarty 3
    

    【讨论】:

    • 没有成功,但最后我能够转储对象,我在 $smarty->template_filepath 中找到了它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-04
    • 1970-01-01
    • 2015-01-11
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多