Вопрос

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.

Это было полезно?

Решение

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.)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top