0

Drupal 8.6.1

I have some menu items I would like to hide from some users: An administration menu with documentation about site admin; A contributors menu with documentation for contributors. etc.

It appears that Drupal prefers every menu entry to link to something. I have these menus pointing to route:<nolink> and have the content hanging from them, tagged as required to implement https://www.drupal.org/project/permissions_by_term.

The result of this is that the top level menu items are visible to everyone.

Is the Drupal philosophy to create some content/view and assign permissions to that for these top-level menus?

0

Is the Drupal philosophy to create some content/view and assign permissions to that for these top-level menus?

Obviously there is no hard and fast rule about this, but generally speaking your hunch is correct. Drupal menus expect every link (even a parent) to link to some content. As an example, the "add content" link goes to a page that lists the available content types even though the content types are usually listed under "add content" in the menu anyway.

add content menu

I do not believe there is an example in core where a menu link is there only as a parent and does not link anywhere.

  • Yes. It took me a while to get my head around that. Seems like a great way to hide content. Anyway, that being the case, is there an easy way to keep a menu in sync with the items in a view? – Aaron Oct 12 '18 at 19:31
  • none that I know of .. but if that is your question, I would ask it separately. Someone else might have a good idea for you but they will never see your question in that comment. A quick google gave me this which is a bit old but might help point you in the right direction: reinisfischer.com/drupal-create-dynamical-menus-menu-views – bleen Oct 14 '18 at 0:30
0

route:<nolink> is relatively new in core (since 8.2) but also what would you rely on to check access for an item that doesn't go anywhere?

You can manually assign menu item permissions through Menu Item Role Access.

Or create your links lists through Views (Block Display). There you can assign Access by Role or existing Permission. That may be the most flexible solution if you are able to filter out your target content this way.

  • > what would you rely on to check access I was rather hoping Drupal would hide the menu if there were no available items on it I've taken a look at menu item role access, but I'm having an issue there too. Issue 3005803 I'm hearing you WRT Views. It doesn't seem like the easiest option at this stage, but I agree, it would be very flexible. – Aaron Oct 12 '18 at 19:20

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.