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

Extend actionEdit Method

Discussion in 'XenForo Development Discussions' started by rellek, Sep 12, 2013.

  1. rellek

    rellek Well-Known Member


    let's assume, I wanted to add something to some admin template. I created a class for my extension controller, I registered it, I created a listener. Now I'd like to make a variable available to the response view in actionEdit.

    Question: How would I do this?

    I found @Jake Bunce's post about how to extend the actionSave method, but I'm afraid this doesn't really help here?!

  2. Daniel Hood

    Daniel Hood Well-Known Member

    Not sure which class you're referring to so I went with AddOn (it was the first result). $viewParams is what sends the data to the template to be used. So you would just insert a new array element.

    public function actionEdit()

    $addOnId $this->_input->filterSingle('addon_id'XenForo_Input::STRING);
    $addOn $this->_getAddOnOrError($addOnId);

    $viewParams = array(
    'addOn' => $addOn,

  3. rellek

    rellek Well-Known Member

    So that means I have to re-implement the whole original method in this case?
  4. Daniel Hood

    Daniel Hood Well-Known Member

    Not entirely. could you explain a little more what you're extending/doing?
  5. rellek

    rellek Well-Known Member

    I want to display an extra set of data in the forum edit page. I created an admin template mod with an Owen variable in it. This variable needs to be included in the variable $viewParams. To not break other addons and to keep it upgrade-safe, I'd rather not completely override a method.
  6. Daniel Hood

    Daniel Hood Well-Known Member

    I'm not at the computer but you're looking for something like

    Function actionEdit()
    $parent parent::actionEdit();
    $viewParams $parent->params;
    $viewParams['Owen'] = "test";
    $this->responseView (''''$viewParams);
    rellek likes this.
  7. rellek

    rellek Well-Known Member

    Yeah, this looks good. Thanks. Not on the computer too atm, but will try once I come back :)
  8. Daniel Hood

    Daniel Hood Well-Known Member

    Ok. ->params may be the wrong name. I'll check if I beat you back to a computer.

    [update] just checked. The code I gave you should work
    Last edited: Sep 13, 2013
  9. rellek

    rellek Well-Known Member

    Thanks, this works great. (y)

Share This Page