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

$allowed_children stopped working!


Go to End


2 Posts   5173 Views

Avatar
imagic

Community Member, 12 Posts

18 August 2011 at 1:42pm

Edited: 18/08/2011 1:45pm

Hi Guys,

This is driving me nuts.

Full code is

<?php
class ProblemPage extends GardenPage
{	
	static $allowed_children = array("Page", "QuestionPage");

	static $has_many = array (
		'Problems' => 'Problem'
	);
	
	
	public function getCMSFields()
	{
		$f = parent::getCMSFields();
		$f->addFieldToTab("Root.Content.Problems", new DataObjectManager(
			$this,
			'Problems',
			'Problem',
			array('Name' => 'Name','Tags' => 'Tags', 'DOMThumbnail' => 'Thumbnail'),
			'getCMSFields_forPopup'
		));
		return $f;
	}
 
}

class ProblemPage_Controller extends GardenPage_Controller {
	
}

All page types display in the dropdown and you are able to create any one of them.. the code has no effect.

I'm using the latest silverstripe version. and the code was working before!

No idea why it's not working anymore!

If anyone could help, that would be awesome!

Avatar
martimiz

Forum Moderator, 1391 Posts

18 August 2011 at 11:27pm

Adding a pagetype to the $allowed_children array, will add all its subclasses as well. so by adding 'Page' you effectively allow all pagetypes that extend Page. To avoid that, you need to prefix the pagetype with an *:

static $allowed_children = array("*Page", "QuestionPage");