I have a website where some pages are only viewable by organization members. Since I try to keep as much as possible public, these pages aren't grouped in a particular section. This module works great for preventing people without the right privs to view the pages. However, it also removes those pages from the menu (and submenutree). I understand that this makes them completely hidden for security, but in my case, people aren't generally going to be logged in so they don't know they're missing content on the site when they browse. So I have to explain to people that they need to sign in and then more content appears to them.

Is there a way to show the page's menu item even if they're not allowed to view the page? Then when someone not signed in clicks on it, they will get the usual access denied/sign in page and can sign in at that time. Or is there a different module I should use for this purpose?

Ideally, there would be some sort of tag on these menu items too so I could style them differently like a members only link.

Comments

gordon’s picture

Status: Active » Closed (works as designed)

This was actually a bug in Drupal 5.x where nodes could not be accessed but menu items would remain visible.

In Drupal 6.x they redeveloped the menu system and part of this redevelopment was to fix this issue. This is something that is built into Drupal and simple access has not control over.

nzcodarnoc’s picture

Ok - I get that it's by design. But is there a way to change the default behaviour?

I'm aware this might not be the best place to ask this question, but I am loath to cross post.

nzcodarnoc’s picture

I've answered my own question, http://drupal.org/project/restricted_content turned out to do what I wanted.

tingdongc’s picture

You can also use node type template to control access, for example create a node-CONTENT_TYPE.tpl.php, print the $content only when logged in:

<div id="content">
<?php
global $user;
if ($user->uid) { // this user is already logged in
    print $content;
} else {
    drupal_set_message(t("Please log in first."));
    $querystring = $_GET;
    unset($querystring['q'], $querystring['destination']);
    $destination = drupal_get_destination() . urlencode('?' . drupal_query_string_encode($querystring));
    $url = url('user') . '?' . $destination;
    header( 'Location: ' . $url );
    exit;
}
?>
</div>

Of course you need to set in template.php to use this node-CONTENT_TYPE.tpl.php, which is very well documented.