Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Uploadify: patch which sets folder dropdown to $uploadFolder by default

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: 2249 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default Link to this post

    I can't troubleshoot something I can't replicate!

    Here's what I'm doing:

    1) Change upload folder using the dropdown.
    2) Click "change"
    3) Click "browse"
    4) Select file
    5) Go to Files & Images, open the selected upload folder, and file is there.

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default Link to this post

    didn't work.

    ok here's what i'm doing. from the begining

    1) Login and /admin
    2) choose the page with the dataobject
    3) clicking the "Add N A M E Object"
    4) choosing "assets/Services" from the dropdown selection
    5) clicking the change button
    6) browse files.
    7) continue button
    8) typing an image description (at this step you can see the uploaded image and the image path. path is always "assets/Uploads/name.jpg"
    9) finish button

    where could be the error?

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default Link to this post

    ok i played around a little bit and now i think to know what could be the problem.

    i build this imagedataobject

    ScreenObject

    <?php
    class ScreenObject extends DataObject {

       public static $db = array(
          'Description' => 'Text'
       );

       public static $has_one = array(
          'Screen' => 'Image',
          'ReferencePage' => 'ReferencePage'
       );

       public function getCMSFields_forPopup() {

    return new FieldSet(
    new TextField('Description', 'Beschreibung'),
    new ImageField('Screen', 'Screenshot')
    );

    }
       
    }

    ?>

    and included it into this page

    ReferencePage

    <?php
    class ReferencePage extends Page {
          
    ...
    ...
       
       public static $has_many = array(
          'Screens' => 'ScreenObject'
       );

       function getCMSFields() {
          
          $fields = parent::getCMSFields();
          
    ...
    ...
          
          $fields->addFieldToTab('Root.Content.Screens', new ImageDataObjectManager($this, 'Screens', 'ScreenObject', 'Screen', array('Description' => 'Beschreibung'), 'getCMSFields_forPopup'));
          
    ...
          
          return $fields;
          
       }
       
    ...
    ...

    }

    class ReferencePage_Controller extends Page_Controller {

    }
    ?>

    at first. is there an any mistake i made?

    ok.

    now im uploading an image

    1) choose the ReferencePage
    2) clicking the Screens Tab
    3) clicking the "Add Screen Object" Button
    4) choosing "assets/folder" from the dropdown selection
    5) clicking the change button
    6) browse files.
    7) waiting until the upload is complete

    Now the image is in the right folder. BUT to save the image into the imagedataobject i have to click continue button and now a copy of the image is moved to uploades and saved there. and this copy is shown on my site and not the original one in the right folder

    do you know what i mean?

    is there a mistake in my code?
    how can i solve this problem?

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default Link to this post

    can no one help me? it's very important and urgent!

  • JonoM
    Avatar
    Community Member
    103 Posts
  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default Link to this post

    Thx, so i have to add this

          $fields->addFieldToTab('Root.Content.Screens', $refscreens = new ImageDataObjectManager($this, 'Screens', 'ScreenObject', 'Screen', array('Description' => 'Beschreibung'), 'getCMSFields_forPopup'));
          $refscreens->copyOnImport = false;

    to my pagetype? right?

    //edit: i added it to my ReferencePage.php and it doesn'T work. what should i do? i'm new to this :/

    I Solved it!!!!!! THX!!!!!
    i did this like told in the link you posted

    // $upload_folder = $form->Fields()->fieldByName('UploadedFiles')->uploadFolder;
    // $folder_id = Folder::findOrMake($upload_folder)->ID;
    // if($file->ParentID != $folder_id) {
    // $new_file_path = $this->uploadFolder.'/'.$file->Name;
    // copy($file->getFullPath(), BASE_PATH.'/'.ASSETS_DIR.'/'.$new_file_path);
    // $clone = new $file_class();
    // $clone->Filename = $new_file_path;
    // $clone->ParentID = $folder_id;
    // $clone->write();
    // $id = $clone->ID;
    // }

    2249 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.