Skip to content

Instantly share code, notes, and snippets.

Created March 11, 2014 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/88b3c1182ffbd8be8961 to your computer and use it in GitHub Desktop.
Save anonymous/88b3c1182ffbd8be8961 to your computer and use it in GitHub Desktop.
<?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