Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » How do I get ImageDataObjectManager to work?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 4102 Views
  • Roweena
    Avatar
    Community Member
    28 Posts

    How do I get ImageDataObjectManager to work? Link to this post

    I've got FileDataObjectManager set up and working ok but I want to use ImageDataObjectManager. I'm following the instructions at http://doc.silverstripe.org/doku.php?id=modules:dataobjectmanager&s=imagedataobjectmanager but the instructions for ImageDataObjectManager as follows:

    "The ImageDataObjectManager takes the same arguments and configuration as a FileDataObjectManager. The only difference is that its only allowed file classes are Image or subclasses thereof"

    ...don't mean much to me as I'm not a developer.

    Can any one help with how to set this up or provide some example code?

    Thanks

  • UncleCheese
    Avatar
    4085 Posts

    Re: How do I get ImageDataObjectManager to work? Link to this post

    Did you see the docs for FileDOM? That would be a good place to start. The only difference is that it manages images, not just generic files.

  • Roweena
    Avatar
    Community Member
    28 Posts

    Re: How do I get ImageDataObjectManager to work? Link to this post

    Thanks for the quick reply?
    Where can I find these docs?

  • UncleCheese
    Avatar
    4085 Posts
  • Roweena
    Avatar
    Community Member
    28 Posts

    Re: How do I get ImageDataObjectManager to work? Link to this post

    I'm already looking at that, I've set up the file manager and it's working ok but I just don't know which bits of code I need to change and what I need to replace with to make the ImageDataObjectManager work?

    Thanks again

  • UncleCheese
    Avatar
    4085 Posts

    Re: How do I get ImageDataObjectManager to work? Link to this post

    It works exactly the same. Just change "FileDataObjectManager" to "ImageDataObjectManager"

    e.g...

    new FileDataObjectManager(
    $this,
    'SomeObjects',
    'SomeObject',
    'SomeFile',
    array('Foo' => 'Foo', 'Bar' => 'Bar')
    );

    becomes..

    new ImageDataObjectManager(
    $this,
    'SomeObjects',
    'SomeObject',
    'SomeFile',
    array('Foo' => 'Foo', 'Bar' => 'Bar')
    );

    The only requirement is that "SomeFile" in that example is an Image or Image subclass.

  • Roweena
    Avatar
    Community Member
    28 Posts

    Re: How do I get ImageDataObjectManager to work? Link to this post

    Thanks again for your help, I've changed the bits I think shoudl be chanegd as per yoru instructions but the resources tab is just showing blank in the cms, ie the tab is there but has nothing in it. My code is as follows, I'm sure I'm missing something:

    class ResourcePage extends Page
    {
       static $has_many = array (
          'Resources' => 'Resource'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new ImageDataObjectManager(
             $this, // Controller
             'Resources', // Source name
             'Resource', // Source class
             'Attachment', // File name on DataObject
             array(
                'Name' => 'Name',
                'Description' => 'Description',
                'Category' => 'Category'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
    $f->addFieldToTab("Root.Content.Resources",$manager);
    return $f;
    }

    }

    AND

    class Resource extends DataObject
    {
       static $db = array (
          'Name' => 'Text',
          'Description' => 'Text',
          'Category' => "Enum('2009, Transitional-Spaces, Brighton-Bands')"
       );
       
       static $has_one = array (
          'Attachment' => 'Image',
          'ResourcePage' => 'ResourcePage'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Name'),
             new TextareaField('Description'),
             new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
             new FileIFrameField('Attachment')
          );
       }
    }

  • Roweena
    Avatar
    Community Member
    28 Posts

    Re: How do I get ImageDataObjectManager to work? Link to this post

    Ok, so following on from the above post, I've got FileDataObjectManage to work fine, but when I change the code (to the code pasted in last posted) I get a blank image/resource tab in the cms admin, where I should be seeing the image upload buttons/functions. Any ideas?

    4102 Views
Page: 1 2
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.