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

What is the best way to alter simple functionality in a large method?

Discussion in 'XenForo Development Discussions' started by SpecialK, Sep 13, 2016.

  1. SpecialK

    SpecialK Member

    In this case, I'm working with the XenForo_ControllerPublic_Forum::actionForum() method. All I need to do is change this line:

    $threadsPerPage XenForo_Application::get('options')->discussionsPerPage;
    and replace it with my own bit of code. What is the best way to do this? I know I could just copy the entire method into my extension method, but that is awfully hacky and a short term solution. If you had to change that line in the actionForum method, how would you go about it?
  2. Chris D

    Chris D XenForo Developer Staff Member

    You can temporarily override option values at run time:
    So you would just extend the class, and set the value before returning the parent:

    public function actionForum()

  3. SpecialK

    SpecialK Member

    Boom. That's exactly what I was wanting to do, but I didn't mention it because I thought it might be the wrong way to go about it and didn't want to look stupid :)

    Thanks Chris!

Share This Page