php to find main menu

Permalink
Hi all,

I'd like to change the style of the body according to the menu i'm in. So for example when i'm in one of the pages of the first main menu there's a blue background image and when i'm in the second main menu (or its children) i'll have another background image.

How should i procede..

 
jordanlev replied on at Permalink Best Answer Reply
jordanlev
You could use the name of the section you're in as a class name, then use css to style those classes appropriately. For example, you could change the <body> tag in your theme templates to this:
<?php
$cPath = $c->getCollectionPath();
$cPathParts = explode('/', $cPath);
$cSection = (count($cPathParts) > 1) ? $cPathParts[1] : '';
?>
<body class="<?php echo $cSection; ?>">
ronwiersma replied on at Permalink Reply
thanks, it works

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.