change submenu color

Author Message

viraj hoober

Tuesday 26 October 2010 3:01:47 am

Hi. I have to change my submenu color according to the menu selected. The menus have different colors. When clicking on a menu say Home with red color how can i have the submenu with the same color?

Some help would be greatly appreciated.

Lo' F.

Tuesday 26 October 2010 4:43:51 am

Hi viraj, you may set a submenu class through an if condition according to its parent node id.

You should already have your list of fetched items..

{def $submenu_items = fetch( 'content', 'list', hash( 'parent_node_id', $root_node.node_id, ...}

then inside the foreach loop...

{foreach $submenu_items as $key => $item}..

..declare and set the item class according to its parent node id..

..
{def $item_class=""}
{if $item.parent_node_id|eq([here goes the actual parent node id])}
    {set $item_class = "[here goes your style-class-name]")}
{/if}
{if $item.parent_node_id|eq([here goes the other parent node id])}
    {set $item_class = "[here goes the other style-class-name]")}
{/if}
{if $item.parent_node_id|eq([again like above])}
    [..and so on depending on the main menu items you have]
{/if}

and then include the class in the item tag..

<a .. class={$item_class}>{$item.name}</a>

and of course set the classes in your css file

.class-name1 {color: #red;}
.class-name2 {color: #green;}

loredanaebook.it

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.