Jeremy
in memoriam 1991-2020
OK,
Here's a confusing on. Mike sorta knows the situation. For my add-on BB Code Manager I needed to extend XenForo_ControllerPublic_Help. According to Mike, if I did:
That it'd work. In essence, this sorta did. It added addMyTemplateVar to the params array just fine. However, it seems that it rendered the view already, so it produced a display error (since I was using it in a foreach()). Now, my next "solution" was to do that, then create a new ResponseView with the $params again. Now, this worked, but it didn't have mediaSites defined in $var->params. Which it should, if I was correct (I had some guidance from Mike here)? Here's my final code:
So my solution was to ad to $var->params[] the ['mediaSites'] again using the model call found in parent. But, again, this is basically what I hard originally started with. Maybe params[] was the wrong variable to use, but I basically end up with the same code I started with, just with a more unreadable sense: the 'copied' code from XenForo. Maybe a bug? Maybe not? Maybe just using the wrong variable?
Here's a confusing on. Mike sorta knows the situation. For my add-on BB Code Manager I needed to extend XenForo_ControllerPublic_Help. According to Mike, if I did:
PHP:
public function actionBbCode()
{
$var = parent::actionBbCode();
$var->params['addMyTemplateVar'] = 'Hello';
return $var;
}
That it'd work. In essence, this sorta did. It added addMyTemplateVar to the params array just fine. However, it seems that it rendered the view already, so it produced a display error (since I was using it in a foreach()). Now, my next "solution" was to do that, then create a new ResponseView with the $params again. Now, this worked, but it didn't have mediaSites defined in $var->params. Which it should, if I was correct (I had some guidance from Mike here)? Here's my final code:
PHP:
public function actionBbCodes()
{
$viewParams = parent::actionBbCodes();
$viewParams->params['mediaSites'] = $this->getModelFromCache('XenForo_Model_BbCode')->getAllBbCodeMediaSites();
$viewParams->params['customBbCodes'] = $this->getModelFromCache('KingK_BbCodeManager_Model_CustomBbCode')->getAllActiveCustomBbCodes();
return $this->_getWrapper('bbCodes',
$this->responseView('XenForo_ViewPublic_Help_BbCodes', 'help_bb_codes', $viewParams->params)
);
}
So my solution was to ad to $var->params[] the ['mediaSites'] again using the model call found in parent. But, again, this is basically what I hard originally started with. Maybe params[] was the wrong variable to use, but I basically end up with the same code I started with, just with a more unreadable sense: the 'copied' code from XenForo. Maybe a bug? Maybe not? Maybe just using the wrong variable?