• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Override methods in Template Class

infis

Well-known member
#1
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?
 

Mike Tougeron

Well-known member
#2
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.
 

infis

Well-known member
#3
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.
 

infis

Well-known member
#5
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.
 

infis

Well-known member
#7
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.