Jump to:

5554 Posts in 1742 Topics by 1227 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Page type "X Page" is not allowed on the root level

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

Page: 1
Go to End
Author Topic: 307 Views
  • padster
    Avatar
    Community Member
    3 Posts

    Page type "X Page" is not allowed on the root level Link to this post

    I can not for the life of me get a custom admin working, I've followed the docs here:

    http://doc.silverstripe.org/framework/en/reference/sitetree

    and keep getting the error:

    Page type "X Page" is not allowed on the root level

    I want my articles administered through the left menu and not appearing as sub pages in the site tree.

    Article Holder .php

    <?php
    class ArticleHolder extends Page {
    private static $allowed_children = array('ArticlePage');
    private static $default_child = 'ArticlePage';
    }

    <?php
    class ArticlePage extends Page {
       private static $db = array(
       'Date' => 'Date',
       'Author' => 'Text'
    );

       private static $allowed_children = 'none';
       private static $can_be_root = false;

       public function getCMSFields() {
        $fields = parent::getCMSFields();
       
        $dateField = new DateField('Date', 'Published Date');
        $dateField->setConfig('showcalendar', true);
        $dateField->setConfig('dateformat', 'dd/MM/YYYY');
       
        $fields->addFieldToTab('Root.Main', $dateField, 'Content');
        $fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');
       
        return $fields;
       }

       public function populateDefaults() {
        $this->Date = date('Y-m-d');
        $this->Author = 'Patrick';
        parent::populateDefaults();
       }

    }

    class ArticlePage_Controller extends Page_Controller {
    }

    class ArticleAdmin extends ModelAdmin {
    private static $managed_models = array('ArticlePage'); // Can manage multiple models
    private static $url_segment = 'articles'; // Linked as /admin/products/
    private static $menu_title = 'Articles';
    private static $icon = "cms/images/treeicons/news-file.gif";
    }

    class Article extends DataObject {
    // ...
    private static $searchable_fields = array(
    'Page Name',
    'Content'
    // leaves out the 'Price' field, removing it from the search
    );
    }

    Help much appreciated, once cracked I can fly through my other parts.

  • padster
    Avatar
    Community Member
    3 Posts

    Re: Page type "X Page" is not allowed on the root level Link to this post

    Anyone? I've been staring at existing add ons trying to see what I missing here, just to shed more light, using "Simple" theme and sub page of this appears in the menu.

  • camfindlay
    Avatar
    Forum Moderator
    148 Posts

    Re: Page type "X Page" is not allowed on the root level Link to this post

    If you are getting that "Page type "X Page" is not allowed on the root level" then it is likely to do with the "private static $can_be_root = false;".

    On another note, if you want to exclude certain page types from the SiteTree you can use the https://github.com/micschk/silverstripe-excludechildren module.

    Hope that helps.

  • padster
    Avatar
    Community Member
    3 Posts

    Re: Page type "X Page" is not allowed on the root level Link to this post

    Hi Cam

    Thanks for replying, I'm confused though.

    Say you create a "Blog" - when you publish articles to said blog you don't want them to show in the site tree, instead the blog publishing really wants to come from a link on the left menu, click into it and add the page from there.

    The problem I have is that when I add a page from there it's showing in the main navigation.

    The site I am trying to build is going to be very modular, pages will be very basic to provide content the client will add, but the vast structure is defined by linking to the modules like:

    Blog
    Events
    Galleries
    etc

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