Silverstripe: outputting DataObjectManager in template include
Posted
by
Fraser
on Stack Overflow
See other posts from Stack Overflow
or by Fraser
Published on 2012-06-18T03:13:29Z
Indexed on
2012/06/18
3:16 UTC
Read the original article
Hit count: 163
php
|silverstripe
I have followed the tutorial here http://doc.silverstripe.org/old/modules:dataobjectmanager to create a dataobjectmanager in my CMS.
It's all working perfectly there however I am having an issue getting it to output in the template. My code is as follows
<?php
class InfoArea extends DataObject{
static $db = array(
'Title' => 'Varchar(255)',
'Content' => 'HTMLText'
);
static $has_one = array(
'ResortPage' => 'ResortPage'
);
public function getCMSFields_forPopup(){
return new FieldSet(
new TextField('Title'),
new SimpleTinyMCEField('Content')
);
}
}
ResortPage.php
.......
static $has_many = array (
"InfoAreas" => "InfoArea"
);
.......
$fields->addFieldToTab("Root.Content.AdditionalInformation",
new DataObjectManager(
$this,
'InfoAreas',
'InfoArea',
array('Title' => 'Title','Content'=>'Content'),
'getCMSFields_forPopup'
));
........
I have a template "ResortPage.ss" which has an include "ResortInfo.ss". It is from within this include file that I need to output the DataObject.
I have tried the below but it doesn't output anything
<% control InfoArea %>
$Title
$Content
<% end_control %>
What am I doing wrong here?
Thanks
© Stack Overflow or respective owner