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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

setAllowedFileTypes(array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'psd', 'ai', 'zip', 'rar', 'exe')); - Still need help!


Go to End


12 Posts   6727 Views

Avatar
borriej

Community Member, 267 Posts

26 November 2010 at 6:31am

Edited: 26/11/2010 6:32am

Thanks to Zauberfisch i managed to disable uploadify:
_config:
DataObjectManager::allow_assets_override(false);

Then I went into the normal SS Files & Images
And was able to upload a .doc!

I could link the file to my page by choosing (in uploadify on my extended page) -> 'existing file tab' - selected the doc.
Continue/Save button.

..And then the template showed the doc, with the correct name & path.
Which doesn't happen when i upload it through uploadify.

Please help me uncle cheese :D

Avatar
borriej

Community Member, 267 Posts

26 November 2010 at 6:45am

Edited: 26/11/2010 6:46am

Source code

<?php



class publicDownloadPage extends Page {

	static $has_many = array (
		'Downloads' => 'Download'
	);
	
	public function getCMSFields() {
    $fields = parent::getCMSFields();
    $manager = new FileDataObjectManager(
      $this,
      'Downloads', // relation name
      'Download', // class name of the DataObject
      'File', // name of the file relation in the DataObject
      array(
			 'Title' => 'Title',
			 'Comment' => 'Comment',
	 	), // headings
      'getCMSFields_forPopup' // name of the function for the popup fields
    
    );

	
	$fields->addFieldToTab('Root.Content.Files', $manager);
    return $fields;
  }

}

class publicDownloadPage_Controller extends Page_Controller {
 
}

class Download extends DataObject {

	static $db = array (
		'Title' => 'Text',
		'Comment' => 'HTMLText',
	);
	static $has_one = array (
		'File' => 'File',
		'publicDownloadPage' => 'publicDownloadPage'
	);
	
	public function getCMSFields_forPopup() {
		$fields = new FieldSet();
		$fields->push(new TextField('Title'));
		$fields->push(new SimpleTinyMCEField('Comment'));
		$fields->push(new FileUploadField('File','Upload files'));
		return $fields;
	}
	
	public function onBeforeWrite() {
		parent::onBeforeWrite();
		if(!$this->Title && $this->FileID) {
			$this->Title = $this->File()->Name;
		}

		if(!$this->Comment) {
			$this->Comment = "None";
		}
	}


}

Avatar
borriej

Community Member, 267 Posts

27 November 2010 at 11:28pm

Still having this problem, can some one help me?

Avatar
GXG2010

Community Member, 4 Posts

5 March 2011 at 3:51am

Hi borriej,

Try to edit file /sapphire/email/mime.types.

Search for msword and add new office extensions.
by ex change line:

application/msword doc dot
with
application/msword doc dot docx dotx

Go to Top