Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Show Pages that the user Can Acess

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1072 Views
  • jsaade
    Avatar
    Community Member
    18 Posts

    Show Pages that the user Can Acess Link to this post

    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

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Show Pages that the user Can Acess Link to this post

    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

  • jsaade
    Avatar
    Community Member
    18 Posts

    Re: Show Pages that the user Can Acess Link to this post

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

    1072 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.