Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Go to End
Author Topic: 58252 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    I've added a lang file. Translate away!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

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

    Attached Files
  • Bo_Einzeller
    Avatar
    Community Member
    18 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

    Attached Files
  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

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

    Thanks for the German. Adding it now.

  • schellmax
    Avatar
    Community Member
    126 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    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!

  • robinp
    Avatar
    Community Member
    33 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

  • cmswarrior
    Avatar
    Community Member
    13 Posts

    Re: Preview: DataObjectManager module Link to this post

    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!

    58252 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.