0
votes

I am creating custom twig templates for a Drupal 8 theme. I want to render a menu in a region only if the node has a menu link (i.e. when editing the node the menu settings on the right has been configured so the “provide a menu link” box has been checked).

Ideally I would like to create this in the twig template so I can change the layout accordingly, but any pointers greatly appreciated!

1
Please edit your post to show you've made some effort, in particular show some code. Learn How to ask a question properly on SO!Alvin Bunk

1 Answers

1
votes

Usually this issue is handled differently(by creating a separate content type and set visibility) but for the sake of the question I'll give some solutions.

Solution 1: Block Visibility Groups.

If that is not enough.

Solution 2: hook_block_view_alter(or any other hook_ENTITY_TYPE_view_alter) where you can deactivate the access to menu block after you check if condition is met with Drupal::routeMatch() to check what node is displayed.