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

Remove 'ArticlePage' from 'Page' (backend)


Go to End


3 Posts   1137 Views

Avatar
homezonebenny

Community Member, 2 Posts

22 June 2011 at 10:24pm

Hi,

I hope that I'm right here in this category of this forum, my "search words" didnt find anything about my questsions:

Can I remove the "ArticlePage" from the backend "create site drop down menu", if I only create a child from "Page"???
If I create a child from "ArticleHolder" I have only "ArticlePage" as the PageType, because I coding this:
public static $allowed_children = array('ArticlePage');

That you can understand what I mean i took this example from the tutorial:
http://doc.silverstripe.org/sapphire/en/tutorials/2-extending-a-basic-site

I found no static propertie like:
static $allowed_parents = array();

So I think that I need to setup all allowed PageTypes (children) in Page.php, BUT if I allow "Page" as a child from "Page", I have all sup Types again (heredity).

Here a screenshoot to understand:
http://imageshack.us/f/850/navigation.png/

I tryed:
static $can_be_root = false;
this works great BUT only in the root, not as a child from "Page" >.<

Thx for your help.

Greetings
Benjamin

Avatar
martimiz

Forum Moderator, 1391 Posts

23 June 2011 at 1:48am

I don't think there is such a thing as allowed_parent. There is a $default_parent in the SiteTree but that doesn't seem to do very much.

To add the Page class only and exclude all it's extensions, use the asterisk: $allowed_children = array('*Page');

To make things even more flexible you could extend the SiteTree's allowedChildren() method. This function returns an array of ClassNames used to build the create dropdown. Extending it in your Page class, you could manipulate the array and remove classes based on the current page's pagetype. Or whatever other logic you might want to add...

Avatar
homezonebenny

Community Member, 2 Posts

23 June 2011 at 3:21am

Hmmm, that produce so much overhead :-\

I try to put "ArticlePage" and "StaffPage" out of "Page" Childs. Only if the "parent" is "ArticleHolder" you can choose "ArticlePage".
All classes that exends "Page" are autom. in the SiteTree, perhaps they should not, a $add_to_tree = "true"; or something like that should do this. So you could enable this in all classes manually and remove this from "ArticlePage" and "Staffpage"...

Hmm, or a function "remove_from_tree" or something like that for the "ArticlePage / StaffPage" so that they are not in the "Page" child list, only as child of "ArticleHolder".

Argh :-D dont know ^^