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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Versioned Extension not working for DataObject


Go to End


2 Posts   934 Views

Avatar
PeterLu

Community Member, 8 Posts

14 May 2015 at 8:05pm

Hi,

I have created a DataOject class called "Slide", which is used for HomePage Slides.
And I have added "Versioned" extension to config.yml
After /dev/build?flush, the CMS does not seem to have Versioning UI for that Slide Class
Any ideas?

Here is my code.
config.yml
Slide:
extensions:
- Versioned("Stage","Live")

Slide.php
class Slide extends DataObject {

private static $db = array (
'Title' => 'Varchar',
'CtaText' => 'Varchar',
'CtaUrl' => 'Varchar'
);

private static $has_one = array (
'Photo' => 'Image',
'HomePage' => 'HomePage'
);

private static $summary_fields = array (
'GridThumbnail' => '',
'Title' => 'Title of slide',
'CtaUrl' => 'CTA'
);

public function getGridThumbnail() {
if($this->Photo()->exists()) {
return $this->Photo()->SetWidth(100);
}

return '(no image)';
}

public function getCMSFields() {
$fields = FieldList::create(
TextField::create('Title'),
TextField::create('CtaText', 'Call To Action text'),
TextField::create('CtaUrl', 'Call To Action url'),
$upload = UploadField::create('Photo')
);

$upload->getValidator()->setAllowedExtensions(array(
'png','jpeg','jpg','gif'
));
$upload->setFolderName('slide-photos');
$upload->setAllowedMaxFileNumber(1);

return $fields;
}

public function getCMSValidator() {
return new RequiredFields('Title', 'Photo');
}
}

Avatar
Pyromanik

Community Member, 419 Posts

15 May 2015 at 12:00am

The Versioned extension provides the functionality, there is no UI for it.
CMS module provides this for pages. Along with the rest of the CMS UI.