By lodderig on
How do I achieve that menu items appear for anonymous users in drupal 6, even when they do not have the rights to access the underlying nodes? (So that I can refer to a custom 403 page). By default Drupal does not display items referring to nodes that are not accessible for that user's role.
I succeeded in doing the opposite (not displaying menu items for nodes with access rights for anonymous users) by means of the menu access module, but the other way arround does not work.
Any suggestions?
thx
Lod
Comments
What exactly do you want to
What exactly do you want to achieve? A custom 403 page is generally not relevant with Drupal b/c access to Drupal is allowed, whereas 403 means no access--what I mean is that Drupal provides its own version of a 403.
Perhaps check out: http://drupal.org/project/protected_node or similar modules.
I want to display a menu item linked to an unaccessible node
Thanks.
I'm looking for a way to display a menu item without giving access rights for the underlying node as it used to be in Drupal 5.
An anonymous user should see the full menu structure of the members menu, without having access to underlying nodes when they click the menu item. e.g. in a menu called 'Services' an anonymous user should see the item 'legal advice' but when clicking this menu item is redirected to a page with an invitation to become a member, while memebers should see the page where is written how to get the advice.
I have tried a combination of the modules content access, custom 403 and menu item access, but this does not work out.
Me too
I used to have a restricted page called 'agents' show in the primary menu, when they clicked on the menu item the page would say it is denied however it would show a login box. It was perfect, I didn't need the login box in the UI cluttering and confusing things. However now I can't show the menu item to get to this restricted page any longer.
Does anyone have an idea on how to get a restricted node to show in the menu?
Stu
same problem, did you managed
same problem, did you managed to solve it ?
I would like to learn this
I would like to learn this too. My only thought would be to hard-code the menu links, and that is not the way I want to do it.
I think
I think so
-----------------------
quang cao online | quang cao
subscribe
subscribe
I did a workaround and I'll
I did a workaround and I'll describe it for anyone who wants to read.
Modules Used: Nodeaccess
My main goal (for this example, there were more obviously) was to have 3 links.
- Home
- Resources
- Contact
ROLES:
- anonymous
- authorized
- Friends
What I wanted:
I wanted the site to output all 3 menu links to anonymous users. If the user clicks home, they get the home page. If the user clicks Contact, they get the contact page. If they click "Resources" however, they would get a page that says they are not authorized to see it and they need to login. On this page, they would get a login box to login, forgot PW links, and register links. Only if you are logged in and have the role "Friends", would you be able to see the Resources.
What I did (originally, before problem):
I was using the Nodeaccess. How I had it set originally was anonymous users had access to Home and Contact when I clicked "Access Control". For Resources however, I unchecked anonymous & authorized, but had "Friends" checked. I thought this would work. However, when I went back to the site as anonymous (not logged in), I could only see Home and Contact. Oh damn.... If I logged in under an account with the "Friends" role, I could see all 3 links.
How I fixed it:
So I can't see the Resources link. But I CAN set access. so what I did was I created a NEW page, called (you guessed it) "Resources". However, this Resources would have have access to only the "Friends" role, and not anonymous or authorized.
SO, if you are admin, your Menu looks like this:
- Home (ALL HAVE ACCESS)
- Resources (ACCESS: anonymous, authorized | NO ACCESS: Friends)
- Resources (ACCESS: Friends | NO ACCESS: anonymous, authorized)
- Contact (ALL HAVE ACCESS)
(i know, there are 2 Resources, but whatever)
So now in the Resources (anonymous access one), I input the following code in the Page (PHP Input Filter):
I also throw in a few links like
<a href="/user/register">to register, and<a href="/user/password">in the PHP input as well.This page would be displayed for anonymous users.
In the OTHER Resources Page, I have all the resources listed out, only visible to Friends role in Access Control.
SO
When an anonymous user goes to the site, they see the menu links: Home, Resources, Contact
- If they click Resources, it takes them to the Page that has the user login form (via the PHP code)
- They don't see the real "Resources" link because they don't have access to that.
Now they login. (lets assume they have Friends role)
- Now the user sees the menu links: Home, Resources, Contact.
- If they click Resources, it takes them to the Page that has all the resources on it
- They don't see the anonymous Resources (login version) link because they don't have access to that
Voila.
Now, I may have done something completely ridiculous/wrong, but it works.
NOTE: there is the permission "administer nodes". If a role has that permission enabled, they will see BOTH menu items
- It will look like Home | Resources | Resources | Contact
but then again, thats only for the Roles that have that permission. For my example, "Friends" have that permission disabled, so they only see 1 Resources link.
Hope this helps, and if anyone has any other suggestions (w/o hacking any code), please let me know.
path redirect
One way - maybe the easiest way? - to solve this problem is to create a bogus page with open access (so the menu link will be happy) and use path_redirect to transfer the linked page to the restricted access URL.
Personally I think the menu logic is too clever by half - I'd love to have the option to nail the menu to the wall and deal with handling any access issues at the link target.
Paul N.