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

Function Override

S

Syndol

Guest
#1
I understand how to to override a function that resides in a file in the ControllerPublic folder, but am not sure how to do the same for a function in ViewPublic/Helper/Node.php

Thank you.
 

dmnkhhn

Active member
#2
Does that answer your question?

MyAddon/ViewPublic/Helper/Bla.php
PHP:
class MyAddon_ViewPublic_Helper_Bla extends XenForo_ViewPublic_Helper_Alert
{
    public function myFunction()
    {
    }
}
 
S

Syndol

Guest
#3
I have tried that but unless I am doing something wrong it does not work.
As for even listener, do I use load_class_controller for this? I have tried load_class_view just in case but no luck either.
 
R

ragtek

Guest
#4
Shouldn't it be
PHP:
[/COLOR]
[COLOR=rgb(0, 0, 0)]class MyAddon_ViewPublic_Helper_Bla extends XFCP_MyAddon....[/COLOR]
[COLOR=rgb(0, 0, 0)]
load_class_controller
To use this event properly, determine if the class is one you want to extend. If so, add a new entry to $extend with the name of the class that should extend it. This class MUST be defined as follows:

class My_Class_Name extends XFCP_My_Class_Name { // functionality to extend/override }[/COLOR]
This class must extend the non-existent XFCP_x class. This will be resolved at run time.
[/php]
 

Indigo

Active member
#6
It doesn't look like this is currently possible. None of the calls are using any kind of dynamic class loading, it's just hardcoding XenForo_ViewPublic_Helper_Node::functionName(...).

However, for now, you should be able to override XenForo_ViewPublic_Forum_View, XenForo_ViewPublic_Forum_List, and XenForo_ViewPublic_Category_View using the load_class_view event listener. In those three, just replace renderHtml() to use your helper instead of the default one.
 
S

Syndol

Guest
#7
Indigo, thank you very very much. I can now at least work with that :)

Edit:
Some functions must still be hard coded as they are not accessible to be overridden.