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.

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


Go to End


379 Posts   95931 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

15 April 2009 at 7:43am

I've added a lang file. Translate away!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

15 April 2009 at 8:58am

Just in case anyone needs it, attached is the old example code.

Attached Files
Avatar
Bo_Einzeller

Community Member, 18 Posts

18 April 2009 at 1:19am

I had some problems with ->allowUploadFolderSelection(). When i selected a folder, i received an error after uploading some Files. The problem is, the folderpath in the database (Silverstripe 2.3.1) had an '/' in the end. So i've added the following line in FileDataObjectManager.php on Line 495:

if(substr($path,-1)=="/") $path = substr($path,0, -1);

UncleCheese, thanks for adding a lang-Folder to the module. I attach my german-translations.

Cheers

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 April 2009 at 1:44am

Thanks, Bo! I love when people report and fix bugs in the same post! :)

Thanks for the German. Adding it now.

Avatar
schellmax

Community Member, 126 Posts

20 April 2009 at 9:49pm

i just had a little issue using filedataobjectmanager to upload mixed media files (jpg as well as flv).
as i have to set the $has_one relation to 'File' for this purpose, i didn't get thumbnails of the images in the cms, but an 'image file' icon, which doesn't help much.
so i changed the 'FileIcon' method in 'FileDataObjectManager.php' to the following:

	public function FileIcon()
	{
		$field = $this->parent->fileFieldName."ID";
		$file = DataObject::get_by_id($this->parent->fileClassName, $this->item->$field);
		if($file && $file->ID) {
			if($file instanceof Image) { 
				$img = $file; 
			} else {
				$ext = $file->Extension;
				$imgExts = array('jpg','jpeg','gif');
				if(in_array($ext, $imgExts)) {
					$img = new Image_Cached($file->Filename);
					$img->ID = $file->ID; //image resize functions require an id
				}
			}			
			return (isset($img)) ? $img->CroppedImage(50,50)->URL : $file->Icon();			
		}
		else return "{$this->item->$field}";
	}

this works great for me, but might not be the most elegant solution.
i was looking for some sort of 'casting' the original file object to an Image object but didn't get far (oop primer).
maybe you got some better solution and want to integrate it in the module code for others too

Avatar
UncleCheese

Forum Moderator, 4102 Posts

21 April 2009 at 3:50am

This is a pretty good fix. I think I'll check it in. Just to give you some background, the main struggle with this issue is that the FileDataObjectManager will display the actual images as icons if the file is of the Image class. So it seems logical that one could "sniff out" an image on upload based on its extension (the assets manager does this), and store it as an Image object rather than a File object if everything checks out. The problem is, that may work 99% of the time, but if someone is using an image subclass, we've now shorted that object of any custom methods and/or properties of its subclass. So as you can see, it gets a little complicated.

I like the idea of handing it right on the template, though. That's a good workaround for now. Thanks for your contribution!

Avatar
robinp

Community Member, 33 Posts

21 April 2009 at 5:14pm

Hi,

I'm using DataObjectManager with dataobject that has about 800 records. The live search is quite slow and search starts before the user has typed in the full search.

I cann't see any code where I could turn off the live search ? Does anyone have any ideas ?

Cheers

Robin

Avatar
cmswarrior

Community Member, 13 Posts

22 April 2009 at 12:06am

Hey Everyone,

I'm using ManyManyDataObjectManager, it works fine. But i have not been able to figure out a way to limit the objects shown in the grid to only the objects associated with the page, currently it shows everything then adds a check mark to the object if it is associated with the page. I can't use the filter clause, because it's a many to many relationship. I am guessing i will have to use a join clause, but still not sure of how to go about it.

Please any hints will be much appreciated.

Awesome Module - Great Job UncleCheese and everyone who has contributed !

Thanks!

Go to Top