Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

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

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 4129 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    Re: setAllowedFileTypes(array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'psd', 'ai', 'zip', 'rar', 'exe')); - Still need help! Link to this post

    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

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: setAllowedFileTypes(array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'psd', 'ai', 'zip', 'rar', 'exe')); - Still need help! Link to this post

    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";
          }
       }

    }

  • borriej
    Avatar
    Community Member
    267 Posts
  • GXG2010
    Avatar
    Community Member
    4 Posts

    Re: setAllowedFileTypes(array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'psd', 'ai', 'zip', 'rar', 'exe')); - Still need help! Link to this post

    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

    4129 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.