Created
November 22, 2016 14:36
-
-
Save anonymous/4e4fae57a5e15274d5cec89260f52a71 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 ItemBlocks extends DataObject { | |
private static $db = array( | |
'Title' => 'Varchar(255)', | |
'Content' => 'HTMLText', | |
'ClassGroup' => 'VarChar(255)', | |
'SortOrder' => 'Int' | |
); | |
private static $has_one = array( | |
'Page' => 'Page', | |
'ItemImage' => 'Image' | |
); | |
public static $summary_fields = array( | |
'ItemImage' => 'Image', | |
'Title', | |
'Content', | |
'ClassGroup' | |
); | |
private static $casting = array( | |
'ClassGroup' => 'VarChar' | |
); | |
public static $default_sort = 'SortOrder'; | |
public function Content() { | |
$content = HTMLText::create(); | |
$content->setValue($this->Content); | |
return $content; | |
} | |
public function getCMSFields() { | |
$fields = new FieldList(); | |
$itemImage = UploadField::create('ItemImage', 'An header image for an item')->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); | |
$fields->add($itemImage); | |
$fields->add(TextField::create('Title', 'Title')); | |
$fields->add(HTMLEditorField::create('Content', 'Content')); | |
$fields->add(TextField::create('ClassGroup', 'ClassGroup')); | |
return $fields; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment