Skip to content

Instantly share code, notes, and snippets.

Created November 22, 2016 14:36
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/4e4fae57a5e15274d5cec89260f52a71 to your computer and use it in GitHub Desktop.
Save anonymous/4e4fae57a5e15274d5cec89260f52a71 to your computer and use it in GitHub Desktop.
<?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