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

Hiding page types and pages in site tree


Go to End


5 Posts   4643 Views

Avatar
Harley

Community Member, 165 Posts

4 September 2009 at 2:51am

If I have a site with various administrators/contributers who all have a different level of access to their part of the site, how can I make sure that in the drop down of 'page types' only certain page types relevant to that administrators section are available to them.

Also in the site tree I want to hide the pages not available to them.

How can I do this?

Regards

Avatar
bummzack

Community Member, 904 Posts

4 September 2009 at 3:36am

Have a look at the canCreate, canEdit, canView, canDelete, canPublish and canAddChildren method of the SiteTree Class (sapphire/core/model/SiteTree.php).

You can override these methods in your Page class to implement the desired access restrictions

Avatar
Harley

Community Member, 165 Posts

8 September 2009 at 8:45am

That's great, thanks for the advice.

Also though I need to know how to be able to not display pages in the site tree on the left pane that don't apply to a particular user.

So for instance if I'm only permitted to update a news page, all I would like to see is the news page in the site tree, not the contact us and about us pages.

Is that at all possible?

Avatar
bummzack

Community Member, 904 Posts

8 September 2009 at 10:23am

Some things can already be done with the page access-settings. For a solution like yours, you'll probably have to implement some of the methods I mentioned previously.
The pages in the dropdown can be limited, by checking the current user and his access-rights in the "canCreate" method and returning true (can create) or false (cannot create).
I'm not sure if there's an easy method to hide pages from showing up in the site-tree. Maybe you'll have to subclass site tree and implement the desired behavior yourself. I never did this, so I cannot tell you if that would be an easy thing to do.

Avatar
danzzz

Community Member, 175 Posts

29 July 2012 at 11:55am

I solved it with adding this to tree.css

ul.tree li .disabled {
display: block;
}

each pagetyp get css attr "disabled" which can't "viewed". -> canView function