@somaboy - Another thing to try is if you're running Firefox, right-click on the popup window and select "Open Frame in new Tab" and see if in the new tab the upload button appears. I've had a few people say that the popup interferes with the javascript required to execute the flash upload.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
DataObjectManager Module /
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
Preview: DataObjectManager module
Hi Uncle Cheese,
511 $label = $file->Title;
now works to show the filename but if I add a specific "$manager1->setGridLabelField('Name');" I can't get it to show the "Name" variable. I tried removing the XML_val from a previous line ie:
509 $label = $this->obj($this->parent->gridLabelField);
but that displayed the previous error. I'm not worried about only displaying the filename I just thought you might like to know :)
Thanks,
Howard
Okay, undo everything. I think I've got it.
public function FileLabel()
{
if($this->parent->gridLabelField) {
$field = $this->parent->gridLabelField;
$label = $this->$field;
}
else if($file = $this->obj($this->parent->fileFieldName))
$label = $file->Title;
else
$label = "";
return strlen($label) > 30 ? substr($label, 0, 30)."..." : $label;
}
Perfect :) tested both with and without a custom setGridLabelField. Thanks!
Hello again,
Four quick points,
1 - setSingleTitle on DataObjectManager doesn't appear to be working... It doesn't error just displays the default
2 - Is there an easyish way to change the width of the columns?
3 - Is there a way to set the default view to be either list or grid?
4 - Is there a way to have images that we upload to a FileDataObjectManager field be displayed as thumbnails (not icons) along side document icons in the grid view?
Certainly don't feel like you have to add these features but thought I would ask if there is a way that I could get any or all of them working.
Thanks for all you work :)
Hi, Howard,
First, undo all the changes you made to the code, and do an SVN update.
1 - setSingleTitle on DataObjectManager doesn't appear to be working... It doesn't error just displays the default
==> You may not understand the function of SingleTitle. It is the text that displays on confirmation of the record being saved. "Saved $SingleTitle successfully." To change the button text, use setAddTitle().
2 - Is there an easyish way to change the width of the columns?
==> No, but that's a good suggestion. Right now, it is subject to the same equal width columns that a non-width defined table is subject to. This was a limitation of ComplexTableField, as well. I could envision something like this:
$manager->setColumnWidths(array(
'Name' => '20',
'Description => '60',
'Date' => '20'
));
// Expressed as percentages
3 - Is there a way to set the default view to be either list or grid?
==> $manager->setDefaultView('list'); or $manager->setDefaultView('grid');
4 - Is there a way to have images that we upload to a FileDataObjectManager field be displayed as thumbnails (not icons) along side document icons in the grid view?
==> This is something I'm really struggling with. Here's the problem. You've defined your object to have a $has_one with a File. So on upload, it creates a new object of the class you've specified -- File. Plain File objects, of course, don't get the image resizing functionality, so you're stuck with an icon. One thought is to evaluate the extension of the file on upload and force class Image if it's a JPG. But then you're disregarding the class that was spec'd in the DataObject. If someone had, for instance, a custom File or Image class, now they get stuck with Image, which they didn't ask for.
I know there has to be some latitude there -- evaluating class ancestry, etc.. I hope to figure something out soon, because I agree, it would be nice.
Thanks again for your feedback. Let me know how you do with those updates.
Hi UncleCheese
You could check if the file has the Resizing-Method. This would also be true, if there's a custom class which extends image.
Use $file->hasMethod('croppedImage') to evaluate if its an Image-Class or not.
Understood, but if the file is added with ClassName "File," that will never return true. The problem is that files with extension .jpg get added as $file = new $className, where $className is the class of the $has_one relationship (most of the time, File).
It's a question of whether we want to force the Image class on file types that, for all intents and purposes, should be store as Image objects. The Files and Images section of SS does this, but gets away with it because it's not managing relationships. When you change the class name of a related object, you're adding a lot of risk, and i could see it breaking stuff pretty easily.