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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Show Pages that the user Can Acess


Go to End


3 Posts   1686 Views

Avatar
jsaade

Community Member, 18 Posts

19 March 2011 at 11:15pm

Edited: 19/03/2011 11:30pm

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

Community Member, 598 Posts

30 March 2011 at 11:49pm

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

Community Member, 18 Posts

12 April 2011 at 8:02pm

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