Skip to content

Instantly share code, notes, and snippets.

@MaxLynam
Last active October 5, 2015 19:47
Show Gist options
  • Save MaxLynam/2865584 to your computer and use it in GitHub Desktop.
Save MaxLynam/2865584 to your computer and use it in GitHub Desktop.
Joomla - Custom CSS dependant on active menu item & children
<!-- START - class decalaration as well as check itemID, frontpage, etc - Max Lynam | @MaxOnTheHill -->
<?php
/* get current active page */
$active = JFactory::getApplication()->getMenu()->getActive();
?>
<body
<?php if ($itemId): ?> id="item<?php echo $itemId; ?>" <?php endif; ?>
class="<?php echo $active->alias; ?>
<?php if ($isFrontpage): ?>frontpage <?php endif; ?>"
>
<!-- END - class decalaration - Max Lynam | @MaxOnTheHill -->
Joomla - Custom CSS dependant on active menu item & children
Author: Max Lynam | June 2012 | max@molehill.com.au
/*************************************************************/
Edit the file "index.php" in your default template directory.
The alias of your active item will be inserted as a class on your body.
If the menu item alias is "home", you can then style everything on that page using the class body.home page.
example usage:
/**** CSS File ****/
body rightcolumn
{
/* rule for every page */
}
body.home rightcolumn
{
/* different rule for homepage */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment