Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

Show Pages that the user Can Acess


Reply

3 Posts   1079 Views

Avatar
jsaade

19 March 2011 at 11:15pm (Last edited: 19 March 2011 11:30pm), Community Member, 18 Posts

I am trying to figure out if there is a way to hide the pages from the site tree that the logged in user cannot access.
I do not want different user groups to "peek" on each others pages.
Is there a simple way to do so?

Edit: I tried using Simplify Module, and my problem with it is when I have the following Structure:

- Page A -> User Cannot Edit
- SubPage 0 -> User Can Edit

if the Parent Page is not editable, Simplify hides it and all tis children even if a child was editable.
Is there a way to fix it?
Thanks

Avatar
Carbon Crayon

30 March 2011 at 11:49pm Community Member, 598 Posts

Hi Jsaade,

Thas has always been a discussion and as yet there is no solid solution, mainly due to the use case that you mention whereby a parent page will be hidden even if the child page is editable.

What I have done in the past is check for edit permissions in my getCMSFields() funtion and return an empty fieldset or message if not, something like so:

   public function getCMSFields()
   {
      if($this->canEdit())
      {
         $fields = parent::getCMSFields();
         $fields->addFieldToTab('Root.Content.Main', new TextField('MyText'));
      }
      else
      {
         $fields = new FieldSet(
            new LiteralField('','<p>You cannot edit this page</p>')
         );
      }
      
      return $fields;
   }

It's not the ideal solution, but can work reasonably in some situations.

Aram

Avatar
jsaade

12 April 2011 at 8:02pm Community Member, 18 Posts

I used simplify + Security Groups and it works, after a lot of tweaking.