Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2014 23:17
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/d7f153ab66ca85839d32 to your computer and use it in GitHub Desktop.
Save anonymous/d7f153ab66ca85839d32 to your computer and use it in GitHub Desktop.
<?php
class TestPage extends Page{
private static $db = array(
'Caption' => 'Text'
);
function getCMSFields(){
$fields = parent::getCMSFields();
$config = GridFieldConfig_RecordEditor::create();
$fields->addFieldToTab('Root.Slider',
TextareaField::create('Caption')
);
return $fields;
}
public function getColour() {
// Try returning banners for this page
$Caption = $this->fieldByName('Caption');
if ( $Caption ) {
return $Caption;
}
// No colour for this page? Loop through the parents.
$parent = $this->Parent();
if ( $parent->ID ) {
return $parent->getColour();
}
// Still need a fallback position (handled by template)
return null;
}
}
class TestPage_Controller extends Page_Controller {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment