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: 58339 Views
  • Andre
    Avatar
    Community Member
    125 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi, I didn't find if this has been answered before so sorry it it has.

    Is there a way to build DataObjects containing more than one Image or File?

    What I want to build is a Project Object containing some Description, a Project Title, a Preview Picture, a normal Picture and a File (flv).

    Code for the Project Object looks the following:

    class ProjectObject extends DataObject{
    static $db = array (
    'Description' => 'Text',
    'ProjectVideoWidth' => 'Text',
    'ProjectVideoHeight' => 'Text',
    );

    static $has_one = array (
    'PreviewProjectPicture' => 'Image',
    'ProjectPicture' => 'Image',
    'ProjectVideo' => 'File',
    'ProjectImagePage' => 'ProjectImagePage'
    );

    public function getCMSFields_forPopup(){
    return new FieldSet(
    new TextareaField('Description'),
    new ImageField('PreviewProjectPicture'),
    new ImageField('ProjectPicture'),
    new FileField('ProjectVideo'),
    new TextField('ProjektVideoWidth'),
    new TextField('ProjektVideoHeight')
    );
    }
    }

    This should be alright, but now I have no Idea, how to build the ProjectObjectPage.

    class ProjectObjectPage extends Page{

    static $has_many = array (
    'ProjectObjects' => 'ProjectObject'
    );

    public function getCMSFields(){
    $fields = parent::getCMSFields();
    $manager = new DataObjectManager(
    $this, // Controller
    'ProjectImages', // Source name
    'ProjectImage', // Source class
    'PreviewProjectPicture', // File name on DataObject
    'ProjectPicture', // File name on DataObject
    'ProjectVideo', // File name on DataObject
    array(
    'Description' => 'Description',
    'ProjectVideoWidth' => 'ProjectVideoWidth',
    'ProjectVideoHeight' => 'ProjectVideoHeight'
    ), // Headings
    'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
    // Filter clause
    // Sort clause
    // Join clause
    );

    $fields->addFieldToTab("Root.Content.Projects", $manager);
    return $fields;
    }
    }

    I think, this is crap, but how can I add more than on File to DataObjects?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    @martimiz - I'm not exactly sure what you're looking for. Just a fancier ImageField? SWFUploadIFrameField should give you what you need. I'm using it on several of my projects.

    @Andre - You can absolutely have multiple files linked to a DataObject, but you can't use a FileDataObjectManager for that. You have to use a straight DataObjectManager, which you're doing, but you're just cramming a bunch of extra arguments in there, so it's probably just erroring out.

  • Andre
    Avatar
    Community Member
    125 Posts

    Re: Preview: DataObjectManager module Link to this post

    I am sorry, I was so stupid, just take DataObjectManager instead of ImagaDataObjectManager.

    class ProjectObjectPage extends Page{
    static $has_many = array (
    'ProjectObjects' => 'ProjectObject'
    );
    public function getCMSFields(){
    $fields = parent::getCMSFields();
    $manager = new DataObjectManager(
    $this, // Controller
    'ProjectImages', // Source name
    'ProjectImage', // Source class
    array(
    'Description' => 'Description',
    'ProjectVideoWidth' => 'ProjectVideoWidth',
    'ProjectVideoHeight' => 'ProjectVideoHeight'
    ), // Headings
    'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
    // Filter clause
    // Sort clause
    // Join clause
    );
    $fields->addFieldToTab("Root.Content.Projects", $manager);
    return $fields;
    }
    }

  • vstrazz
    Avatar
    Community Member
    63 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hey guys. I'm having a conflict with complex table field pop-up's in the security section of the CMS when Dataobject_manager is installed. Has anyone else had this issue yet?

    Instead of the pop up the edit form is returned consuming the entire browser page.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    So to replicate this, I just click the Security tab on any site that has DOM installed? 2.3.1? Browser? I'll try it out. Surprised this hasn't been reported yet.

  • vstrazz
    Avatar
    Community Member
    63 Posts

    Re: Preview: DataObjectManager module Link to this post

    Just click the security tab, then click edit on one of the groups.

    I have a ton of other modules and custom work done, but the dataobject_manager folder is default download. I simply moved the dataobject_manager folder out of my root and retried the issue and it was fine.

    NINJA EDIT:// 2.3.1 / Most recent Firefox on XP

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    I can't replicate it in Safari or Firefox. Anyone else?

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Preview: DataObjectManager module Link to this post

    @UncleCheese
    I tried the SWFUploadIFrameField, but having some issues with it (maybe you could point me in the right direction):

    - attach button greys out when you happen to click it before choosing a file
    - treedropdown for existing files hangs om 'loading...'

    (mozilla 3 win)

    So I was thinking: why not have a field that has just a button that uses the popup from the ImageDataObjectManager to add/edit an image, and then maybe shows a thumbnail next to the button. It would keep the cms tabs nice and clean, and still use all extra's from your popup that I like so much, like title, alt and description - much more then the SWFUploadIFrameField does.

    This would work nicely on pages that hold several images - think a book cover, an author photo, a company logo, that would be added separately, and not just as a series of images. Could it be done?

    @vstrazz
    I have the same configuration (2.3.1, XP Mozz 3.0.1) and it works fine for me...
    [edit] I have the latest from the svn (142)

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