How can I limit the number of pages a user can create in a page of a specific type.
One of my category pages should only allow two child pages of a SPECIFIC type. I.e. The category page "Gender" should only be allowed two pages - so if a user have created the pages BOY and GIRL, they should be denied to create another "GenderPage" in the category
I tried to do something like
function canCreate() {
$child = DataObject::get("BoyPage","ParentID = ".$this->ParentID);
if($child->Count() > 1) return false;
return true;
}
but it seems like the parentID & ID fields are uninitialized