Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

DataObject in SiteConfig


3 Posts   812 Views


11 May 2012 at 12:25am Community Member, 2 Posts

I am folllowing a walk through on using the data object manager in siteconfig ( I have managed to get it working to the point where I can add objects to the backend but I can't seem to get them to display on the template.

I am trying to loop through all items inside the object using a control loop but i don't seem to be having any joy... I get an error message [Notice] Undefined index:

SiteConfig Extender

class SiteConfigExtra extends DataObjectDecorator{

function extraStatics() {
return array(
'db' => array(
"phone" => "Varchar",
"email" => "Varchar",
"twitterEmbed" => "HTMLText",
"suppliers" => "HTMLText",
"googleanalytics" => "HTMLText"
'has_one' => array(
"logo" => 'Image',
"slogan" => 'Image',
"defaultbanner" => 'Image'
'has_many' => array(
"nemomembers" => "nemomember"

public function updateCMSFields(FieldSet &$fields) {
$fields->addFieldToTab("Root.Logo", new ImageField('logo', ' Logo (174x79)', Null, Null, Null, 'Uploads/site-assets/'));
$fields->addFieldToTab("Root.Logo", new ImageField('slogan', ' Slogan (483x52)', Null, Null, Null, 'Uploads/site-assets/'));
$fields->addFieldToTab("Root.Main", new TextField('phone',"Phone Number"));
$fields->addFieldToTab("Root.Main", new TextField('email',"Email Address"));
$fields->addFieldToTab("Root.Main", new TextAreaField('twitterEmbed',"Twitter Embed"));
$fields->addFieldToTab("Root.Main", new TextAreaField('googleanalytics',"Google Analytics"));
$fields->addFieldToTab("Root.Main", new ImageField('defaultbanner', 'Default Banner (973x200)', Null, Null, Null, 'Uploads/site-assets/'));
$fields->addFieldToTab("Root.Suppliers", new HTMLEditorField('suppliers',"Suppliers"));

$manager = new DataObjectManager(
$fields->addFieldToTab("Root.NemoMembers", $manager);

class SiteConfig_DataObjectManager extends DataObjectManager {
function setSourceID($val) {
if (is_numeric($val)) {
$this->sourceID = $val;
function sourceID() {
if (isset($this->sourceID) && $this->sourceID !== null && is_numeric($this->sourceID)) {
return $this->sourceID;
return parent::sourceID();


class NemoMember extends DataObject
//db fields
static $db = array (
'Name'    => 'Varchar(255)',
   'Address1'    => 'Varchar(255)',
'Address2'    => 'Varchar(255)',
'Town'    => 'Varchar(255)',
'County'    => 'Varchar(255)',
'Postcode'    => 'Varchar(255)',
'Lat'    => 'Varchar(255)',
'Long'    => 'Varchar(255)',
'Email'    => 'Varchar(255)',
'Telephone'    => 'Varchar(255)'

static $has_one = array (
'Logo'      => 'Image'

//Fields to show in the DOM table
static $summary_fields = array(

    * Fields for DOM popup
    * @param    void
    * @return    FieldSet DOM Object
public function getCMSFields()
return new FieldSet(
new TextField('Name'),
new TextField('Address1'),
new TextField('Address2'),
new TextField('Town'),
new TextField('County'),
new TextField('Postcode'),
new TextField('Lat'),
new TextField('Long'),
new TextField('Email'),
new TextField('Telephone'),
new ImageField('Logo', 'Logo', Null, Null, Null, 'Uploads/member-logos/')


<% control SiteConfig.NemoMembers %>
<% end_control %>

Please help, I have looked through other forum posts and haven't managed to get it to work. Please tell me it's something stupid that I have missed. It is driving me mad not being able to get it to work!

Many thanks,


12 May 2012 at 12:57am Community Member, 3 Posts

I just bumped on the same problem.. So subscribing on this thread
Any help would be awesome!


31 May 2012 at 5:11am (Last edited: 31 May 2012 5:12am), Community Member, 1 Post

You can create functions inside the SiteConfigExtra class that return dataobjects:

function NemoMembers() {
return DataObject::get('NemoMember');

Then you can output them in any template file like this:

<% control SiteConfig %>
<% control NemoMembers %>
<% end_control %>
<% end_control %>