Insert body class name in Joomla
Posted on 25. Mar, 2009 by Michele in Code
I recently had to add a class name per section into a body tag for a Joomla based website I have been working on. After quite a bit of google’ing I found this and it was super useful.
To use the menu alias as the class name
<?php $menu = &JSite::getMenu(); $active = $menu->getActive(); ?> <body id="<?php print $active->alias; ?>">
Use the menu page class suffix
<?php $menu =& JSite::getMenu(); $active = $menu->getActive(); $params = $menu->getParams( $active->id ); $class = $params->get( 'pageclass_sfx' ); ?> <body<?php if ($class) echo ' class="' . $class . '"'; ?>>
Visit this site to view the full discussion thread


