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.

General Questions /

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

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

Children pages to inherit the page type of parent?


Go to End


6 Posts   1666 Views

Avatar
Big Bang Creative

Community Member, 92 Posts

1 May 2009 at 10:18pm

Edited: 01/05/2009 10:19pm

How can I set the default page type of children pages to inherit the page type of the parent.

Avatar
Double-A-Ron

Community Member, 607 Posts

4 May 2009 at 9:47am

Edited: 04/05/2009 9:48am

Not sure if I follow what you are asking entirely, but it sounds like $default_parent and $default_child are what you are after.

http://doc.silverstripe.org/doku.php?id=recipes:customising-the-hierarchy

Cheers
Aaron

Avatar
Big Bang Creative

Community Member, 92 Posts

5 May 2009 at 8:05pm

What I want is if I have a Products page with sub pages i.e.

Products
> Product 1
> Product 2

I want "Product 1" and "Product 2" to inherit the page type of "Products" so that whenever I add in a new product it defaults to the correct page type rather than the "Page" type.

Avatar
Howard

Community Member, 215 Posts

5 May 2009 at 8:29pm

You can include this in any page class and it will restrict the children allowed to whatever is in the array:

static $allowed_children = array('ProductPage');

Avatar
Double-A-Ron

Community Member, 607 Posts

5 May 2009 at 8:33pm

BBC, did you check the link I gave? The very first example shows how to do exactly what you want, using both mine and howard's suggestions in tandem.

Aaron

Avatar
Big Bang Creative

Community Member, 92 Posts

5 May 2009 at 11:05pm

Thanks, I did look at the link but I was confused at first glance. Looking back I now have what I want, it was as you said.. the first part i.e.

static $allowed_children = array("BlogEntry");
static $default_child = "BlogEntry";