Skip to content

Instantly share code, notes, and snippets.

/PicsPage.php Secret

Created August 13, 2013 23:29
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/06671058f462fc32bf8b to your computer and use it in GitHub Desktop.
Save anonymous/06671058f462fc32bf8b to your computer and use it in GitHub Desktop.
<?php
class PicsPage extends Page
{
private static $many_many = array(
"Slider" => "Slider"
);
private static $many_many_extraFields = array(
"Slider" => array(
"Sorting" => "Int"
)
);
}
class PicsPage_Controller extends Page_Controller
{
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab(
"Root.Slider",
new GridField("Slider", "Slider", $this->Slider(),
$slider = new GridFieldConfig_RelationEditor())
);
$slider->addComponent(new GridFieldSortableRows("Sorting"));
$fields->removeByName("Content");
return $fields;
}
public function Slider() {
return $this->getManyManyComponents("Slider")->sort("Sorting");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment