Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Hiding page types and pages in site tree

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

Page: 1
Go to End
Author Topic: 2306 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    Hiding page types and pages in site tree Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Hiding page types and pages in site tree Link to this post

    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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Hiding page types and pages in site tree Link to this post

    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?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Hiding page types and pages in site tree Link to this post

    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.

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: Hiding page types and pages in site tree Link to this post

    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

    2306 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.