05/07/2012 5:07am

PHP | Problem - add_extension not working


##############################

## CustomImageDecorator.php
##############################

<?php

class CustomImageDecorator extends DataObjectDecorator
{

function extraStatics()
{
return array(
'has_one' => array(
'Classification' => 'WorkClassification',
)
);
}

function updateCMSFields(FieldSet &$fields)
{
$classifications = DataObject::get('WorkClassification');

if (!empty($classifications)) {

$fields->addFieldsToTab('Root.Main', new DropdownField(
$name = "ClassificationID",
$title = "Show For Classification",
$source = $classifications->map('ID', 'Name', 'Please Select')
));
}
}

function getClassificationName()
{
if ($this->owner->Classification()) {
return trim($this->owner->Classification()->Name);
}
return false;
}
}


##############################
## _config.php
##############################
// To enable classification of images
DataObject::add_extension('CustomImage', 'CustomImageDecorator');



Post Comment