API page: https://api.drupal.org/api/drupal/core!themes!stable!templates!navigatio...

I try to render the main navigation with all it's child menu items as a menu block in my navigation region. I configured the block under admin/structure/block/manage/THEMENAME as 'Initial menu level' 1 and 'Maximum number of menu levels to display' 2.

The menu has the following hierarchy.

-- menuitem
-- menuitem
-- menuitem (parent)
  -- menuitem (child)

My main navigation consists of 2 levels which get rendered when I navigate to the menu item which has a child (e.g. parent). But I try to build a menu which renders all child elements on every level (also on toplevel / front, not only when I already navigated to the parent page which has a child). E.g. when you try to build a 2-level-hover-menu.

But the variable item.below in menu.html.twig is always empty on toplevel elements respectively if it is not the parent page ... e.g. front.

Any suggestions how to tackle this?

Comments

4aficiona2 created an issue. See original summary.

4aficiona2’s picture

Issue summary: View changes
4aficiona2’s picture

Issue summary: View changes
4aficiona2’s picture

Issue summary: View changes
4aficiona2’s picture

Issue summary: View changes
lewisnyman’s picture

I'm not sure if thing is the same problem but I've seen people get tripped up because they have to enabl the “expanded” option for menu items before they will display their children.

Does that fix your problem?

4aficiona2’s picture

OMG ... searched and debugged for hours but I did not actually head into the menu item itself. After checking the "expanded" option on the menu item the menu + subtree gets rendered as wished.

Thanks a lot for this advice! Saved my day!

4aficiona2’s picture

Status: Active » Fixed

Issue got resolved. Check #6

lewisnyman’s picture

Status: Fixed » Closed (works as designed)

@4aficiona2 I suggest you open another issue to do something about the "expanded" option. Either we remove it or have it on by default. It seems like a clear Themer Experience issue.

4aficiona2’s picture

Title: item.below is empty menu.html.twig on top level menu » item.below is empty in menu.html.twig on top level menu
4aficiona2’s picture

@LewisNyman I opened a new issue where this can get discussed

4aficiona2’s picture

fredlllll’s picture

Sorry to revive this dead thread, but i have the same problem. item.below is always empty in menu.html.twig which can be seen here

Only local images are allowed.

and my menu structure is here

Only local images are allowed.

the item real estate development has "show as expanded" enabled. im using drupal 8.2.6

its kinda critical that this works

alula.k’s picture

I had a similar problem but it turns out I have to configure the navigation block to display multiple levels. Check out
https://www.drupal.org/project/drupal/issues/2892134#comment-12382012