I have used nested DOM before following the very useful video:
http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/nested-dataobjectmanager-a-dom-in-a-dom/
of UncleCheese (btw: Thank you very much for it! ) but I would like to implement something slightly different and I think I am reaching the limit of my understanding of SS. Could someone help me with the following?
I want to implement a multi-column footer, each column being a DataObject with a header (text) and a list of DataObjects ( URLName / URLLink ). For various reasons I do not want to implement this in the SiteTree (as a hierarchy of pages ) but as one unique "Footer" page object.
class Footer extends Page {
..
static $has_one = array (
'Column1' => 'FooterSubmenu',
'Column2' => 'FooterSubmenu'
);
..
}
class FooterSubmenu extends DataObject
{
static $db = array (
'Header' => 'Text',
);
static $has_one = array (
'FooterColumn1' => 'Footer',
'FooterColumn2' => 'Footer',
);
//see http://www.silverstripe.org/data-model-questions/show/18329 for an explanation on the relation above
static $has_many = array (
'RecLinks' => 'RecLink'
);
}
class RecLink extends DataObject
{
static $db = array (
'LinkName' => 'Varchar(30)',
'LinkUrl' => 'Varchar(100)',
);
static $has_one = array (
'DataObject' => 'DataObject'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('LinkName'),
new TextField('LinkUrl')
);
}
}
And here is how I try to create a Footer page in the CMS :
class Footer extends Page {
..
public function getCMSFields()
{
$f = parent::getCMSFields();
$f->removeFieldFromTab('Root.Content.Main', 'Content');
$f->addFieldToTab("Root.Content.Column1", new TextField('Column1.Header'));
$f->addFieldToTab("Root.Content.Column1", new DataObjectManager(
$this,
'Column1',
'FooterSubmenu',
array('LinkName' => 'LinkName','LinkUrl'=>'LinkUrl'),
'getCMSFields_forPopup'
));
$f->addFieldToTab("Root.Content.Column2", new TextField('Column2.Header'));
$f->addFieldToTab("Root.Content.Column2", new DataObjectManager(
$this,
'Column2',
'FooterSubmenu',
array('LinkName' => 'LinkName','LinkUrl'=>'LinkUrl'),
'getCMSFields_forPopup'
));
return $f;
}
..
}
But this does no work because I guess of the 'Column1.Header, 'Column2.Header'
Could someone put me in the right direction, please. I am obviously stuck and...clueless...:-)
Thanks