[support] Pages with restricted access and menu entries.
Martin Tomes
lists at tomes.org
Mon Sep 25 06:41:23 UTC 2006
Jason Flatt wrote:
> On Saturday 23 September 2006 13:41, Martin Tomes wrote:
>> I have defined a page type for pages which should be hidden from
>> anonymous users by writing my own module (an edited copy of page.module)
>> and have set permissions so that only users in specific roles can read
>> those pages. My problem is that if I add that page to a menu that menu
>> entry is shown to anonymous users and I would like it to be hidden from
>> them (they get permission denied on clicking on the menu entry) and only
>> shown to logged in users with view permission. Is there any way to
>> achieve this?
>>
>> --
>> Martin Tomes.
>
> Do you have something like this as part of your menu array?:
I do, but only for the node/add/xxx menu.
> 'access' => user_access('access special page type'),
>
> There are many examples in the core modules in hook_menu functions.
Thank you for you help!
My node type is a variation on page.module so it creates pages with urls
node/<number> and it is these pages I wish to control the visibility of
menu entries for based on the page type. When I create a page of this
type I add it to a menu using the node edit form and it is this menu
entry which I cannot work out how to control.
As I understand it hook_menu() adds menu entries itself, I want to
control the visibility of a menu entry added by the person who created
the page and I don't know in advance where that will be.
I tried this but it didn't work:
$items[] = array('path' => 'node/'. arg(1),
'access' => user_access('view an extranet page'));
--
Martin.
More information about the support
mailing list