7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Adding Files to Images within Image Gallery
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: | 3108 Views |
-
Re: Adding Files to Images within Image Gallery

7 September 2010 at 12:40am
Hey Adrian
It seems you cant use FileDataObjectManager in this way, but you can use regular DataObjectManager to do the same thing, ie;
<?php
class CaseStudy extends Page {static $has_many = array ('CaseStudyImages' => 'CaseStudy_Image');
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Object",$manager = new DataObjectManager($this,'CaseStudyImages','CaseStudy_Image',array('Name' => 'Name','CMSThumbnail'=>'Preview'),'getCMSFields_forPopup',null,"Name Asc"));
return $fields;
}
}
class CaseStudy_Image extends DataObject
{
static $db = array (
'Name' => 'Varchar'
);static $has_one = array (
'Attachment' => 'Image',
'Thumbnail' => 'Image',
'CaseStudy' => 'CaseStudy'
);public function getCMSFields_forPopup()
{
return new FieldSet(
new ImageField('Thumbnail'),
new TextField('Name'),
new ImageField('Attachment')
);
}
function CMSThumbnail() {
if ($image=$this->Thumbnail())return $image->CMSThumbnail();
return null;
}
}This should work regardless of what version you have
-
Re: Adding Files to Images within Image Gallery

7 September 2010 at 12:57am
OK cool, slightly different user journey, but essentially it will work, and it won't mean having to re-upload all of the images again!
Thanks for your help
-
Re: Adding Files to Images within Image Gallery

7 September 2010 at 1:14am
WHAT? Why upload the images again?
You can still attach any images that have already been uploaded to the SS filestore.
Or you could even use a RAW SQL query to update your objects, if the structure has changed soo much?
-
Re: Adding Files to Images within Image Gallery

7 September 2010 at 1:48am
No, I don't need to upload the images. Note the negative
Thanks,
Adrian
| 3108 Views | ||
| Go to Top |

