Created
November 25, 2014 14:02
-
-
Save anonymous/82ba430d66040c023b2b 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 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