Extend actionEdit Method

rellek

Well-known member
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.
 
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);
    }
 
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.
 
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);
}
 
Yeah, this looks good. Thanks. Not on the computer too atm, but will try once I come back :)
 
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:
Back
Top Bottom