Code: Select all
First add this code above the doctype:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive();
$pageclass = '';
if (is_object($menu))
$pageclass = $menu->params->get('pageclass_sfx');
?>
(Many templates have a place to add head code via the Joomla admin)
And this code to your body:
<body class="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
Anything without a page class will use a class of "default", anything with the page class defined will appear as the class entered into “Page Class” in the Menu Manager.
Code: Select all
0 - Cannot access protected property Joomla\CMS\Menu\MenuItem::$params