Override methods in Template Class

infis

Well-known member
How I can override some methods in library/XenForo/Template/Public.php?

Perhaps, there are other ways of obtaining of the full tree of used templates?
I need a tree of templates, and also very much it would be desirable to see immediate all names of templates in the generated page.
Besides it I want not to correct in specific templates some code, and directly in a plug-in to make changes to an output. Hooks there are not present and врядли appear in the near future. If there will be a modification method immediately in an output, what probability to receive a problem at usage of this output in different plug-ins?
 
The way I did it was to use a custom dependencies file and override the createTemplateObject() method.
PHP:
class IGNXF_Dependencies_Public extends XenForo_Dependencies_Public
{
    public function createTemplateObject($templateName, array $params = array())
    {
        .....
        return new IGNXF_Template_Public($templateName, $params);
    }
}
and then in your index.php do:
PHP:
$fc = new XenForo_FrontController(new IGNXF_Dependencies_Public());
There are a couple of places where it may call XenForo_Template_Public directly but as far as I could tell it doesn't impact what I needed to do. Don't know if this will be the case for you but it should be.
 
There are a couple of places where it may call XenForo_Template_Public directly but as far as I could tell it doesn't impact what I needed to do. Don't know if this will be the case for you but it should be.
Yes. Override of XenForo_Template_Public in a new class it is possible and will work. But it demands change of original files that it would not be desirable. It is a pity that there is no possibility to extend with an original class without its full changeover.
Thanks for your variant.
 
The only original files it requires a change in is the index.php and that file rarely (if at all) gets modified.
It's not working properly. Need many changes. And that not show all templates with included templates and cached.
I need to see the list of all templates, including js, css, and also what in cache. A problem that those templates which are compiled and are in cache, they are deduced only without what in this template are included.
 
Yeah, in that case you'll need to recursively query the database once you know what page/template is being loaded. :/
 
Certainly, it is necessary for me only for debugging, therefore runtime is not critical. Unfortunately, there are no regular means to receive such list of templates without modification of original files.
Perhaps, Kier and Mike look at this thread and pay attention to such problem. In my judgement in a development mode such option should be nevertheless.
 
Top Bottom