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.

Blog Module /

Discuss the Blog Module.

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

Add 2nd upload field to blog module


Go to End


1374 Views

Avatar
Skullies

Community Member, 19 Posts

14 June 2016 at 10:43pm

Good day all

I am trying to add a second upload field to my blog module but am having trouble doing so...

The main issue i am currently having is that the FeaturedThumbnail does not show in my cms

what i have tried was:

#1
private static $has_one = array(
'FeaturedImage' => 'Image',
'FeaturedThumbnail' => 'Image',
);

public function getCMSFields(){
Requirements::css(BLOGGER_DIR . '/css/cms.css');
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
$self =& $this;
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
$uploadField = UploadField::create('FeaturedThumbnail', _t('BlogPost.FeaturedThumbnail', 'Featured Thumbnail'));
$uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image'));

$fields->insertAfter($summaryHolder, 'FeaturedImage');
$fields->insertAfter($summaryHolder, 'FeaturedThumbnail');

return $fields;
}

#2
// Create a new file in extensions
<?php
class BlogEntryDecorator extends DataExtension {
static $has_one = array(
'FeaturedThumbnail' => 'Image'
);
public function updateCMSFields(FieldList $fields) {
parent::updateCMSFields($fields);
$fields->addFieldToTab("Root.Main", $FeaturedThumbnail = new UploadField('FeaturedThumbnail'), 'Content');
}
}
// Create add extension in _config
DataObject::add_extension('BlogEntry', 'BlogEntryDecorator');

If anyone can assist in this problem it would be greatly appreciated

Thanks
Skullie