I don't think you can access the original template's properties from a plugin in runtime. But you can use the http://php.net/debug_backtrace function to access the caller place's informations. (Of course this information will be based on the compiled file, not the original. But It is better than nothing.)
Smarty get current template filename / line
Pregunta
I would like to get the current template file / line from a plugin function in smarty for profiling/debugging purposes.
Is it possible to do by using the passed $smarty object ?
something like this
function __smarty_add_javascript($params, $smarty){
Profiler::console('Add javascript @[FILE]#[LINE]');
Controller_Template_Base::getInstance()->javascripts[] = array_pop($params);
}
I am able to access the filename by using $smarty->source->filepath
however i couldnt find any line information.
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow