Created
November 26, 2014 23:17
-
-
Save anonymous/d7f153ab66ca85839d32 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 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