With some CMSs such as Joomla, menus are very powerful features. They can control layouts, permissions, metadata and much more.
In Drupal, menus have almost no power at all. By default, menus are not capable of controlling much more than the destination of their link. So, we end up with a lot of questions from students about menus.
This week a student asked us how they control who can see menu links. This tutorial is our answer.
We're going to show how Drupal menu permissions work and how you can make them more powerful.
Menu Permissions are Controlled by Content
The first and most important thing to realize about Drupal menus is that permissions are controlled by what is being linked to.
The menu link itself does not have any permissions associated with it. Drupal menu links are actually quite weak and powerless features. The power is with the content.
Let me show what I mean. Here's our menu:
The menu link itself does not have any permissions associated with it. Drupal menu links are actually quite weak and powerless features. The power is with the content.
Let me show what I mean. Here's our menu:
"Menu Link 1" is a link to a node called "Content for Menu Link 1".
If I unpublish the "Content for Menu Link 1" ...
... then "Menu Link 1" will automatically become unpublished:
So you can see the menu link is entirely dependent on the content. If the content is unpublished, the menu link will automatically follow.
The same is true of permissions: if the user doesn't have permissions to see content, then any menu links to that content will be automatically hidden.
This pattern holds whether you're dealing with content, Views, Panels or any other content on your site. For example, any menu links to a View are controlled inside the View itself, under PAGE SETTINGS > Access.
The same is true of permissions: if the user doesn't have permissions to see content, then any menu links to that content will be automatically hidden.
This pattern holds whether you're dealing with content, Views, Panels or any other content on your site. For example, any menu links to a View are controlled inside the View itself, under PAGE SETTINGS > Access.
If you're using Panels to create pages, there will be an Access option inside the editing screen:
Adding Permissions to Menus
So we've seen that, by default in Drupal, there are no permissions directly attached to menus.
However, in some situations menu permissions can be useful. For example, if you have a menu link to a URL rather than to a specific content page, you won't have any way to add permissions.
If you do need menu permissions, I recommend the Menu item visibility module:https://drupal.org/project/menu_item_visibility.
Using that module will add a Visibility settings area inside each menu link:
However, in some situations menu permissions can be useful. For example, if you have a menu link to a URL rather than to a specific content page, you won't have any way to add permissions.
If you do need menu permissions, I recommend the Menu item visibility module:https://drupal.org/project/menu_item_visibility.
Using that module will add a Visibility settings area inside each menu link:
No comments:
Post a Comment
Thanks for your comment.