1

I want to have an alternative top menu bar for certain Roles when they are logged in. For example, 'Teachers' have one top menu bar, 'Students' have another type.

For now, I want to do this using Rules, is this a good approach or is there an easier way. Simple functionality is the key here so at this time I'm not looking to hack tpl.php files as I just want to get something working for demo purposes.

I'm using Bootstrap and happy to stay that way for the future.

Any suggestions & advice on the above, most welcome. Thanks in advance.

3 Answers 3

2

When you create a menu, a block should be created at the same time (https://drupal.org/taxonomy/term/32478). Go to Admin, Structures, Blocks and place one of those menus in the area you want it to appear - under Role restriction at the bottom of the block configuration, you can decide who has access to that specific menu. Repeat for each menu - this way, the menu appears in the same spot, but a different menu will appear for different roles.

5
  • Thanks Geoff, I never really considered the Blocks option since I've been messing with others functions within Bootstrap. The above link is handy too, I'll go read it now and get back to your answer when I've made my result. Again, thanks.
    – Paul B
    Commented May 13, 2014 at 21:03
  • Hummh.... I tried that, (and cleared caches). To test, I put a 'Test link' in a 'Teacher' topbar menu (in my case 'Header') and set it only to that role. Normal thing, cleared cache, logged out and back in, result: it shows the same top menu for all members even though only certain roles are 'assigned' to that menu. The 'student' sees also the 'teachers' topbar menu when they really shouldn't. I have missed something here or is my approach incorrect? I'm using Panels for the dashboard layouts, but I doubt that matters. I could be wrong.
    – Paul B
    Commented May 13, 2014 at 21:53
  • Do you have other blocks of content that you can test by restricting by Role? Even just a test block with dummy text that appears on the content area. This might help figure out the next step.
    – Geoff
    Commented May 13, 2014 at 22:28
  • I found some other resources that suggest it may not work with Panels.
    – Geoff
    Commented May 13, 2014 at 23:01
  • Thanks for your reply. I'm also using a number of other functions, namely Workbench, Panels, Rules & more, etc Possible that they are influencing them. Had this issue for weeks, but it's not major at moment, but would like to get it resolved at some point. Will have to get my 'magnifying glass' to look deeper. Anyone else got idea's please drop them by here.
    – Paul B
    Commented May 14, 2014 at 9:12
1

Just navigate to admin/structure/menus

Create menu Students and Teacher and assign some menus into it.

These menus will automatically create two blocks on path admin/structure/blocks Create a region in info file header_menu and render it in page.tpl.php

Now assign both these menus to the same region and restrict its display to roles by its display settings.

enter image description here

Hope it will help!

0
0

I found an alternative to my original question which I have resolved myself, for others, here is the answer to my problem.
What I wanted to do was only show a top-menu bar link to certain members and hidden to others. I resolved this by setting the "Selection Rules" of the page to: User: role: Logged in user has one of 'whatever role you want to allow to show' (i.e Teacher Role) and setting the criteria to 'Only one criteria must pass'. So if set to 'Teacher' when the teacher logs in the menu link shows for them, if the 'student' logs in (which has no permission to view the link) they do not see the said link. It must be stated that link to the page you wish to use, must be in your Menu Links (under the Structure) in my case, the 'Main Menu' links structure.

Maybe there are other ways to do this, but for now a simple result works for what I need for now and I'll probably replace it with some CSS structure, but it works. Try it yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.