Jump to:

7937 Posts in 1537 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: 60353 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    @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.

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    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;
       }

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    Perfect tested both with and without a custom setGridLabelField. Thanks!

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    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.

  • Bo_Einzeller
    Avatar
    Community Member
    18 Posts

    Re: Preview: DataObjectManager module Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    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.

    60353 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.