简体   繁体   中英

Fetch Smarty template name within php

I have registered a block function which takes care of translation.

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

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

Can i somehow determine by using the $smarty object in PHP, which template file caused the function call? Or howelse could i fetch inside php, which template currently is rendered?

The third parameter is the Smarty object. I'm not sure, but you can try

echo $smarty->_current_file; //Smarty 2

or

echo $smarty->template; //Smarty 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM