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