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

Extend actionEdit Method

rellek

Well-known member
#1
Hi,

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?!

Thanks.
 

Daniel Hood

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

PHP:
public function actionEdit()
    {
        $this->assertDebugMode();

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

        $viewParams = array(
            'addOn' => $addOn,
            'LIKETHISONE' => 'TEST!'
        );

        return $this->responseView('XenForo_ViewAdmin_AddOn_Edit', 'addon_edit', $viewParams);
    }
 

rellek

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

Daniel Hood

Well-known member
#6
I'm not at the computer but you're looking for something like

PHP:
Function actionEdit()
{
 $parent = parent::actionEdit();
 $viewParams = $parent->params;
 $viewParams['Owen'] = "test";
return $this->responseView ('', '', $viewParams);
}
 

Daniel Hood

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