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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

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


Reply

12 Posts   4164 Views

Avatar
borriej

26 November 2010 at 6:31am (Last edited: 26 November 2010 6:32am), Community Member, 267 Posts

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

26 November 2010 at 6:45am (Last edited: 26 November 2010 6:46am), Community Member, 267 Posts

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

27 November 2010 at 11:28pm Community Member, 267 Posts

Still having this problem, can some one help me?

Avatar
GXG2010

5 March 2011 at 3:51am Community Member, 4 Posts

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