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

Uploadify: patch which sets folder dropdown to $uploadFolder by default


Go to End
Reply


14 Posts   2414 Views

Avatar
UncleCheese

Forum Moderator, 4096 Posts

3 September 2011 at 2:33am

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.

Avatar
benni91

Community Member, 72 Posts

3 September 2011 at 12:30pm

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?

Avatar
benni91

Community Member, 72 Posts

5 September 2011 at 7:37am

Edited: 05/09/2011 7:37am

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?

Avatar
benni91

Community Member, 72 Posts

5 September 2011 at 11:30pm

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

Avatar
JonoM

Community Member, 103 Posts

5 September 2011 at 11:47pm

Hi Benni,

See http://www.silverstripe.org/dataobjectmanager-module-forum/show/15755?start=8

Avatar
benni91

Community Member, 72 Posts

6 September 2011 at 12:10am

Edited: 06/09/2011 12:44am

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 :D :/

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

Go to Top