By dams-1 on
Hello,
I am new to Drupal and intend to present certain custom pages to certain user roles. I already read How Do I ... hide certain menu's from users in certain role's and Show block to certain users only but can not reach my goal.
I created menu items linked to my pages. Ok with that.
I created blocks using the following code to display them according to a_certain_role of connected user:
global $user;
$output = '';
if (in_array('a_certain_role',$user->roles))
{
$output .= 'YOUR OUTPUT GOES HERE';
}
return $output;
It works but what do I put in place of 'YOUR OUTPUT GOES HERE'? I just want to see my menu items there...
How do I put my menu items in my custom block?
I use Drupal 4.6.3. Thanks in advance for your answer.
Comments
This is what I use
OR For Multiple roles use
$approved_roles = array('authenticated user,story editor,authors');
to Find Menu No. go to menus and hover cursor over "edit" of the menu you want to include in the status bar of your browser you will see something like
http://yourdomain/?q=admin/menu/item/edit/80
the number on the end is the menu number
All the best
gpdinoz
"If we can see further it is because we stand on the shoulders of giants"
Regards
Geoff
Ok for the block, but the menu?
Thanks for your hint. It works well for the block, but in the same time the menu itself still displays: I have the menu items displayed in the block and in the menu. These items are the same by principle here.
How do you let these menu items appear only in the user-role-controlled block?
Disable the "Menu"
When you say "Menu" I assume you mean the "Navigation" Block Menu that is the default. You can turn it off by going to blocks and unchecking the "enabled" checkbox for "Navigation".
gpdinoz
"If we can see further it is because we stand on the shoulders of giants"
Regards
Geoff
Where should We add this Code
Hello
Got the above code. I am new to drupal. but I do not know where to put the code to disable the menu for a particular user role.
It would be great if you could get back to me with the answer.
with regards,
Baburaj
Create a custom block
Create a custom block in admin/blocks an put this code in the block.
gpdinoz
"If we can see further it is because we stand on the shoulders of giants"
Regards
Geoff
Check this comment
http://drupal.org/node/29480#comment-52825
Sunny
www.gleez.com
Developping my own module
Hello,
After having tried many things, I realized I have to develop my own module. I made the tutorial. This way gives a solution to all the technical questions I had with Drupal to reach my goal.
Thank you for your answers. They contribute to teach me Drupal philosophy too.
dams