Jump to:

23553 Posts in 19380 Topics by 2892 members

General Questions

SilverStripe Forums » General Questions » How to limit pages nesting level in CMS

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 408 Views
  • Sewer
    Community Member
    9 Posts

    How to limit pages nesting level in CMS Link to this post

    Hi all,

    I need to set maximum nesting level of pages in SiteTree. For example, content manager should be able to create Page page type in SiteTree root, and as a children of pages - but it should not be possible to create pages under another pages.
    I created simple function, but it doesn't work.

       public function canAddChildren($member = null) {
          if ($this->CurrentLevel() == 1) {
             return true;
          } else {
             return false;

    I used CurrentLevel() function posted by UncleCheese here:

    CurrentLevel works fine when used in getCMSFields(), but in canAddChildren() it always returns 1.

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.