i'd like to control a menu block's visibility based on the depth of the current page.

does menu block provide a function that makes it easy to figure out what the depth is of the menu link that corresponds to the current page? or do i just need to query the menu_links table myself?

would anyone else be interested in a visibilty based on depth feature? or maybe a "ending level will be" configuration to correspond to "starting level will be"?

thanks!

Comments

dilari’s picture

Can you not achieve that by setting the starting level and maximum depth ?
i.e. starting level '2nd level' and maximum depth '1'

firebus’s picture

no. max depth controls how many levels of menu the menu block displays (e.g. maxdepth = 1 means that no expanded children will be displayed in the menu block).

max depth has nothing to do with whether or not the menu block is visible at a given depth.

so if you set starting level to 2nd, you'll see the menu block on any menu item that is 2nd level or deeper.

depending on whether or not you check "Make the starting level follow the active menu item.", the menu block will follow you down, or will stay anchored at the 2nd level.

dilari’s picture

You're right, your suggestion for the 'ending level' is what is missing;
You can make it follow but you can't not display it.

Would be best if it where possible to set visibillity per level.
So: show on level 1, don't show on level 2 & 3 , show on level 4

You could , not dynamically though, set it to not display on certain pages in your block contig.

JohnAlbin’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)