Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2014 14:02
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/82ba430d66040c023b2b to your computer and use it in GitHub Desktop.
Save anonymous/82ba430d66040c023b2b to your computer and use it in GitHub Desktop.
<?php
class ServicePage extends Page {
private static $db = array(
);
private static $has_many = array(
'ServiceIcon' => 'ServiceIcn'
);
function getCMSFields(){
$fields = parent::getCMSFields();
$config = GridFieldConfig_RecordEditor::create();
$fields->addFieldToTab('Root.Main',
GridField::create('ServiceIcon', 'Manage Service Icons', $this->ServiceIcon(), $config)
, 'Metadata');
return $fields;
}
}
class ServicePage_Controller extends Page_Controller {
}
class ServiceIcn extends DataObject {
static $db = array(
'Color' => 'Text',
'Description' => 'HTMLText',
);
static $has_one = array(
'HomePage' => 'HomePage',
'Image' => 'Image'
);
static $summary_fields = array(
'Color',
'Thumbnail'
);
function Thumbnail(){
return $this->Image()->CroppedImage(80, 80);
}
static $singular_name = "Service Icon";
static $plural_name = "Service Icons";
function getCMSFields() {
$fields = FieldList::create(TabSet::create('Root'));
$fields->addFieldsToTab('Root.Main', array(
UploadField::create('Image'),
TextField::create('Title'),
HtmlEditorField::create('Description')
));
return $fields;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment