7913 Posts in 1355 Topics by 930 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, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 1774 Views |
-
Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default

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. -
Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default

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 buttonwhere could be the error?
-
Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default

5 September 2011 at 7:37am Last edited: 5 September 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 completeNow 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? -
Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default

5 September 2011 at 11:30pm
can no one help me? it's very important and urgent!
-
Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default

5 September 2011 at 11:47pm
-
Re: Uploadify: patch which sets folder dropdown to $uploadFolder by default

6 September 2011 at 12:10am Last edited: 6 September 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
:/
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;
// }
| 1774 Views | ||
| Go to Top |


