public function AddForm()
 {
     $form = parent::AddForm();
     $fields = $form->Fields();
     $fields->push(new HiddenField('Parent', null, true));
     // Enforce a parent mode of "child" to correctly read the "allowed children".
     $fields->dataFieldByName('ParentModeField')->setValue('child');
     $fields->insertAfter($parent = new TreeDropdownField('ParentID', '', 'SiteTree', 'ID', 'TreeTitle'), 'ParentModeField');
     $parentID = $this->request->getVar('ParentID');
     $parentID = $parentID ? $parentID : Multisites::inst()->getCurrentSiteId();
     $parent->setForm($form);
     $parent->setValue((int) $parentID);
     $form->setValidator(new RequiredFields('ParentID'));
     return $form;
 }
 /**
  * @return ArrayList
  */
 public function PageTypes()
 {
     $pageTypes = parent::PageTypes();
     $result = new ArrayList();
     $productClass = Object::getCustomClass("Product");
     $productGroupClass = Object::getCustomClass("Product");
     $acceptedClasses1 = ClassInfo::subclassesFor("ProductGroup");
     $acceptedClasses1[$productClass] = $productClass;
     $acceptedClasses2 = ClassInfo::subclassesFor($productGroupClass);
     $acceptedClasses2[$productGroupClass] = $productGroupClass;
     $acceptedClasses = $acceptedClasses1 + $acceptedClasses2;
     foreach ($pageTypes as $type) {
         if (in_array($type->ClassName, $acceptedClasses)) {
             $result->push($type);
         }
     }
     return $result;
 }
<?php

/**
 * The subsites module modifies the behaviour of the CMS - in the SiteTree and Group databases - to store information
 * about a number of sub-sites, rather than a single site.
 */
SiteTree::add_extension('SiteTreeSubsites');
ContentController::add_extension('ControllerSubsites');
CMSPageAddController::add_extension('CMSPageAddControllerExtension');
LeftAndMain::add_extension('LeftAndMainSubsites');
LeftAndMain::add_extension('ControllerSubsites');
Group::add_extension('GroupSubsites');
ErrorPage::add_extension('ErrorPageSubsite');
SiteConfig::add_extension('SiteConfigSubsites');
SS_Report::add_excluded_reports('SubsiteReportWrapper');
//Display in cms menu
SecurityAdmin::add_extension('SubsiteMenuExtension');
CMSMain::add_extension('SubsiteMenuExtension');
CMSPagesController::add_extension('SubsiteMenuExtension');
SubsiteAdmin::add_extension('SubsiteMenuExtension');
CMSSettingsController::add_extension('SubsiteMenuExtension');
CMSMenu::remove_menu_item('SubsiteXHRController');