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.

All other Modules /

Discuss all other Modules here.

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

Attach file (doc,jpg..), in newsletter module


Go to End


2315 Views

Avatar
aimcom

Community Member, 8 Posts

4 June 2010 at 9:09pm

Edited: 04/06/2010 9:10pm

I have found the following solution for your problem:

In your _config.php file, add the following line:

Object::add_extension('Newsletter', 'MyNewsletter');

Create a file called MyNewsletter.php:

<?php

class MyNewsletter extends DataObjectDecorator {
	public function extraStatics() {
		return array(
			'has_one' => array(
				'File' => 'File'
			)
		);
	}
	
	public function updateCMSFields(FieldSet $fields) {
		$fields->addFieldsToTab(
			'Root.Newsletter',
			array(
				new FileField('File', 'File') // doesn't work
			)
		);
	}
}

?>

Furthermore, you have to edit newsletter/code/Newsletter.php and modify the function getCMSFields():

function getCMSFields($controller = null) {
	// ...
	
	$this->extend('updateCMSFields', $ret);
	return $ret;
}

By now, I haven't found a way to make the FileField / FileIFrameField work. Perhaps somebody else has an idea how to solve this issue?