I'm trying to set one of my menu parameters. But I'm getting the error
0 CALL TO UNDEFINED METHOD JOOMLA\CMS\APPLICATION\SITEAPPLICATION::SETPARAMS()
My code is:
$app = JFactory::getApplication();
$app->setParams($appParams['pageclass_sfx'],$pageClass);
And I see setParams as an option in the API https://api.joomla.org/cms-3/classes/Joomla.CMS.Menu.MenuItem.html#method_setParams
I find the API quite difficult to understand without a relevant example. From searching the CMS code on GitHub I found this example:
function setParams($option, $param = false)
{
return $this->IC->set_parameters($option, $param);
}
But that seems to confirm my code is written in the right way. In any case it seems to be saying the method doesn't exist.
Joomla\CMS\Menu\MenuItem
but you're manipulatingJoomla\CMS\Application\SiteApplication
.onAfterRender
is too late. It's used mainly to manipulate the already generated document.onAfterRoute
would probably be most suitable in this case.