Multi level nav problem, need input.

Author Message

Nathan Kelly

Friday 04 November 2005 11:56:39 pm

Hi all, I'm making a multilevel navigation bar and I have run into a small problem, maybe someone here can help?

I'm using unordered lists for my menu with one level of nested ul's, my stylesheet highlights the nested list and the current links. The problem I have is that if you navigate to a link (node) that has children the nested ul is then displayed benieth, but if you navigate to one of those children you end up with two links showing as current.

From a system point of view this is true but from an interface point of view it gets a little confusing for the user.

I'm using the code below to highlight current links and it works fine on the top level but once a child is selected the problem comes into play.

{$s_menu.is_selected|choose('',' class="current"',' class="current-parent"')}

What I need to do is find out what level I'm on and apply the correct class to the link. So if the node is not current there is no class, if the link is current the it has a class="current" appended and if the link is a parent and one of it's children is selected it is appended class="current-parent" while the child is appended class="current".

Wow I hope that makes sense?

Maybe some output will make it clearer?

This is my menu at the top level:-

link1 (below) has no children so its just current or not current.

<ul>
    <li class="current">link1</li>
    <li>link2</li>
    <li>link3</li>
    <li>link4</li>
</ul>

Ok link2 (below) has children but they are not selected so link2 is the current link.

<ul>
    <li>link1</li>
    <li class="current">link2</li>
    <li>
        <ul>
            <li>child link1</li>
            <li>child link1</li>
        </ul>
    </li>
    <li>link3</li>
    <li>link4</li>
</ul>

As it stands now this is what happens when I select child link1 (below) (or any child link).

<ul>
    <li>link1</li>
    <li class="current">link2</li>
    <li>
        <ul>
            <li class="current">child link1</li>
            <li>child link1</li>
        </ul>
    </li>
    <li>link3</li>
    <li>link4</li>
</ul>

What I really need is this (below)

<ul>
    <li>link1</li>
    <li class="current-parent">link2</li>
    <li>
        <ul>
            <li class="current">child link1</li>
            <li>child link1</li>
        </ul>
    </li>
    <li>link3</li>
    <li>link4</li>
</ul>

When a child link is selected the parent has a unique class (current-parent) this way my parent link can now be styled with the same background colour as the ul beneath it.

Wow did that make sense? This is really hard to explain, but if this was straight HTLM coding it would be so simple. Ok so after all that, is there any way I could manipulate this line

{$s_menu.is_selected|choose('',' class="current"',' class="current-parent"')}

to do what I have explained?

I know the is_selected operator probably won't work, I thought I may need to use some if else type statements, I just dont know how to do it though?

Any help is soooo appreciated, if you are unsure of my question I'll do my best to explain better.

Cheers!

Pardon me while I burst into flames...

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 19 2025 15:22:28
Script start
Timing: Jan 19 2025 15:22:28
Module start 'layout'
Timing: Jan 19 2025 15:22:28
Module start 'content'
Timing: Jan 19 2025 15:22:29
Module end 'content'
Timing: Jan 19 2025 15:22:29
Script end

Main resources:

Total runtime0.7226 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 590.3750152.6250
Module start 'layout' 0.00440.0025 743.000039.4453
Module start 'content' 0.00690.7144 782.4453483.3516
Module end 'content' 0.72140.0012 1,265.796912.4688
Script end 0.7226  1,278.2656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.4061160.0002
Check MTime0.00120.1644160.0001
Mysql Total
Database connection0.00070.093010.0007
Mysqli_queries0.682894.4847460.0148
Looping result0.00030.0446440.0000
Template Total0.695696.320.3478
Template load0.00190.261120.0009
Template processing0.693795.998120.3469
Template load and register function0.00010.011010.0001
states
state_id_array0.00130.179310.0013
state_identifier_array0.00110.154620.0006
Override
Cache load0.00150.2145280.0001
Sytem overhead
Fetch class attribute can translate value0.00050.075010.0005
Fetch class attribute name0.00050.062620.0002
XML
Image XML parsing0.00040.061410.0004
class_abstraction
Instantiating content class attribute0.00000.000720.0000
General
dbfile0.00070.1021160.0000
String conversion0.00000.001040.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
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/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: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs