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

How do i replace existing php code in a new addon?

Discussion in 'XenForo Development Discussions' started by otto, Jun 15, 2014.

  1. otto

    otto Well-Known Member


    i have made a litle guide to sort RM items alphabetical. You can see this here:


    i mean this part of my guide above:

    Now i have made a template addon for the TMS changes and the new phrase. See packed zip attachment.

    But what can i do to change the 2 lines in the resource.php (see the linked guide) from the xenforo RM ?

    Can any one help?

    Attached Files:

  2. Jeff Berry

    Jeff Berry Well-Known Member

    You won't be able to extend/override those variables in that controller function, unfortunately there's just no way to do that.

    What you'll need to do is try to extend the _preDispatch() method of the Resource controller (XenResource_ControllerPublic_Resource) and forge what would normally be the user supplied order params from the URL (?order=xxx&direction=ASC).

    To do this, extend the controller like so:

    class XFCP_YourAddon_XenResource_ControllerPublic_Resource extends XFCP_XenResource_ControllerPublic_Resource
       protected function 

            if (
    $action != 'Category')

            if (!

            if (!
    What this is doing is injecting parameters that would normally be passed through the URL. It checks to see if the user is passing these through the URL first, and if not it injects them. It will only take effect on the Category action (actionCategory method in the controller).

    Good luck.
    otto and AndyB like this.
  3. otto

    otto Well-Known Member


    I see AndyB liked your answer also :whistle: - thats also good :D

    Ok, i will try this out. (y)

Share This Page