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.

eZ debug

Timing: Jan 18 2025 02:18:59
Script start
Timing: Jan 18 2025 02:18:59
Module start 'layout'
Timing: Jan 18 2025 02:18:59
Module start 'content'
Timing: Jan 18 2025 02:19:00
Module end 'content'
Timing: Jan 18 2025 02:19:00
Script end

Main resources:

Total runtime0.7440 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.8125152.6094
Module start 'layout' 0.00600.0029 740.421939.4219
Module start 'content' 0.00890.7336 779.8438525.3203
Module end 'content' 0.74240.0015 1,305.16418.1875
Script end 0.7440  1,313.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4303160.0002
Check MTime0.00130.1812160.0001
Mysql Total
Database connection0.00060.085610.0006
Mysqli_queries0.700294.1188540.0130
Looping result0.00060.0758520.0000
Template Total0.714396.020.3571
Template load0.00230.305020.0011
Template processing0.712095.694120.3560
Template load and register function0.00010.015710.0001
states
state_id_array0.00120.162810.0012
state_identifier_array0.00150.195220.0007
Override
Cache load0.00190.2509180.0001
Sytem overhead
Fetch class attribute can translate value0.00050.061020.0002
Fetch class attribute name0.00090.117630.0003
XML
Image XML parsing0.00060.080720.0003
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00080.1138160.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs