Hello everybody,
I'm creating a module and I want to show the versions of the current page. So I wrote the function to get the data. I checked the output with Debug::dump(). It seems to be the right versions. But how can I render this data with a specified template?
At the beginning of loading my cms form the function, which I retrieve the data, will called. The data shall show under my specified tab. But I only get the word 'array'. Furthermore I also add a template, which is called IncludeObjects_version, for rendering my retrieved data.
In the following paragraph I will post my function getCMSFields() and my function versions() to retrieve the data.
public function versions() {
$page = DataObject::get_by_id('IncludeObjects', $id);
if ($page) {
$versions = $page->allversions();
return array(
'Versions' => $versions,
);
}
}
public function getCMSFields($id) {
$fields = new FieldSet(
new TabSet('Root',
new Tab('Content',
new TabSet('Option',
new Tab('Main',
new TextField('IncludeName', _t('IncludeObjectsAdmin.INCLUDENAME','Name'),""),
new TextareaField('IncludeDescription', _t('IncludeObjectsAdmin.INCLUDEDESCRIPTION','Description'),""),
new HTMLEditorField('IncludeContent', _t('IncludeObjectsAdmin.INCLUDECONTENT','Content'),""),
new HiddenField('IncludeUser', _t('IncludeObjectsAdmin.INCLUDEUSER','CurrentUser'), $this->getCurrentMember())
),
new Tab('Log',
new ReadonlyField('ID','Include ID', $id),
new ReadonlyField('LastModifiedUser','Last User', $this->getLogData($id, 'IncludeUser')),
new ReadonlyField('Created', 'Created', $this->getLogData($id, 'Created')),
new ReadonlyField('LastEdited', 'Last Modified', $this->getLogData($id, 'LastEdited')),
new ReadonlyField('LastVersion','Current Version', $this->getLogData($id, 'CurrentVersion'))
),
new Tab('Versions',
new CustomHTMLField('Versions', $this->versions($id))
),
new Tab('Settings',
new ReadonlyField('Publish-Date','Publish-Date', '01.01.2010'),
new ReadonlyField('Owner','Owner','webteam'),
new ReadonlyField('Approval','Approval', 'Jens Armbruster')
)
))) );
if(self::$runCMSFieldsExtensions) {
$this->extend('updateCMSFields', $fields);
}
return $fields;
}
Many thanks for your help!