views:

530

answers:

5

The Drupal 6 menu module hides links to content that the current user does not have permission to access. This makes sense, but there are times when you may want links to be shown and go to a 'you are not authorized to view this content' page (e.g. for marketing purposes).

Is there an easy way to get these links to show? I understand that previous versions of Drupal actually required you to download a module to HIDE the links to unauthorized pages!

+1  A: 

It has always been that way (at least since 4.7).

You cannot unhide unauthorized menu items out of the box. There might be a special module though...

EricSchaefer
+1  A: 

What you could do, is to let the menu page point to a function that redirects to the page that you want your menu to point to. This is not ideal in many ways but since all can access the function that does the redirect this should work. You canjust put this code into a custom module you make.

googletorp
+1  A: 

There is no way to do this in the default Drupal, and I'm not aware of any contributed modules that provides this functionality.

Two solutions come come to mind to do this easily.

  1. With minimal coding is to hide the real menu item and make it invisible, then make a page with some PHP code that redirects to the proper menu item if the user has access, and showing some other text for people who don't. Then just make a menu item that points to your node.

  2. Involves more coding, but it will probably be more robust. Just make your own basic module with a hook_menu that has the opposite access check to the real menu item along with a small menu callback function with the text you want to show non-privileged users.

If you want to do this for a lot of menu items some more flexible solution should be found to manage it properly.

Kjartan
+1  A: 

assuming that every content is a node you can keep menus without access rules and then use

hook_view($node, $teaser = FALSE, $page = FALSE)

you can refuse access to certain nodes ..

hope that's helpful.

Houssem
A: 

I've found a module that actually seems to provide the functionality I want:

http://blog.davereid.net/content/restricted-content-yet-another-different-drupal-node-access-module

It's really simple, it just adds a selector within each node creation page where you can choose what roles will have access to it. Any that don't will still see the menu link, and this will lead to a custom 'you must register to view this' page. I've installed it on a test Drupal site and it seems to work fine; shame I didn't find it a couple of weeks ago!

james6848

related questions