-
-
Save anonymous/88b3c1182ffbd8be8961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Page extends SiteTree{ | |
private static $many_many =array( | |
"PageSections" => "PageSection" | |
); | |
private static $many_many_extraFields = array( | |
'PageSections'=>array( | |
'SortOrder' =>'Int' | |
) | |
); | |
function getCMSFields() { | |
$f = parent::getCMSFields(); | |
$gridconfig = GridFieldConfig_RelationEditor::create(); | |
$gridconfig->addComponent(new GridFieldSortableRows('SortOrder')); | |
$f->addFieldToTab( | |
'Root.Main', | |
$grid = new GridField('PageSection', 'Page Sections', $this->PageSections(), $gridconfig ) | |
); | |
$f->removeByName("Metadata"); | |
return $f; | |
} | |
public function PageSections() { | |
return $this->getManyManyComponents('PageSections')->sort('SortOrder'); | |
} | |
} | |
class Page_Controller extends ContentController{ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment