开发者

Drupal: display menu items even if they link to unauthorized pages

开发者 https://www.devze.com 2023-01-09 17:44 出处:网络
I\'ve a menu item linking to a page开发者_运维知识库 that requires authentication to be visited.

I've a menu item linking to a page开发者_运维知识库 that requires authentication to be visited.

If I'm not logged-in, Drupal hides the menu item, beucase I cannot visit the page.

I would like to change this setting, and display the menu item also to guests with a link to the login page instead.

Thanks


I won't say that it can't be done, but this will be extremely difficult, as you probably have to override the generation of the menu, which is some pretty complicated stuff.

An alternative and much easier solution would be to have both menu items in your menu, but to hide one of them.
If the user just needs to be logged in you can check the body class, as it by default will put a class to show if the user is logged in or not. You can use that to make two different styling rules, hiding the menu item that shouldn't be displayed to user.
If the access check is a bit more complicated, you can do it in the preprocess_page function in your theme and add extra classes to your body tag.

0

精彩评论

暂无评论...
验证码 换一张
取 消