1

My multi-level menu works fine for pages at levels 1, 2 and 3.

{exp:taxonomy:nav 
 tree_id="1" 
 display_root="no" 
 active_branch_start_level="1" 
 depth="3"
    {if {embed:entry_id} }
        entry_id="{embed:entry_id}"
    {/if}
    {if {embed:node_id} }
        node_id="{embed:node_id}"
    {/if}
 }

However, when I reach a URL at level 4, the menu disappears. This is to be expected, because of the depth="3" parameter. If I change it to "4", then my menu expands to show all four levels, but that's not what I want. I want the menu to show only three levels, even if the current URL is in level 4.

How can I show the same 3-level menu at all times, even when I'm on a level 4 page?

2

When you pass an entry_id or node_id parameter, Taxonomy is looking for that active node in the tree and assigns all the appropriate vars like {active}, {active_parent} etc. If the active node is not found in the tree, Taxonomy will not output the nav.

As you're asking for a subset of the tree, flagging that you want an active branch subset, and supplying the active node which doesn't exist in that subset; Taxonomy is not rendering anything.

So, remove the depth param, and wrap the {children} variable in a conditonal, for example:

{exp:taxonomy:nav 
    entry_id="{entry_id}"
    tree_id="1" 
    display_root="no" 
    active_branch_start_level="1" 
}
    <li><a href="{node_url}">{node_title}</a>{if node_level < 3}{children}{/if}</li>
{/exp:taxonomy:nav}

There are a few other ways of doing it, but this would be the most straight forward. Let me know if you're still not getting the results you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.