Jump to:

7940 Posts in 1543 Topics by 946 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: 61018 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    @mr_t - I see what you're getting at, but I think it's a little too far out of scope of the project for me to develop right now. DataObjectManager was built as an extension to the ComplexTableField, so I'd like the functionality to stay parallel for now.

    @everyone who has been trying to fix the FileDataObjectManager on a page issue -- I'm having a hard time replicating this problem. Here's what I've done.

    I've created a has_many relation on my Page class to the example Resource object. Resource has_one Page. In my Page class, I have a FileDataObjectManager for Resources, and I setParentClass("Page");

    I'm able to get every page to have its own resources. What am I missing?

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    @ UncleCheese I really can't say as I have been unable to reproduce the problem myself. But I did post a theory a few posts back. Do you have your DataObject sortable? That forces the ID into the DB and I believe solves any issues the others are mentioning. See my previous post here:


    Ok, this is just a theory, but I am pretty sure it is why my code works with out setting the parent class, or any of the other hoops.
    SortableDataObject::add_sortable_class('SomeDataObject'); (goes in your _config.php)
    This insures you have IDs and maybe this is what make's mine work? I just know that I get all these things for free that people are saying don't work. Anyway, hope this helps someone.
    Just a thought.

  • Amir Mostofi
    Avatar
    Community Member
    59 Posts

    Re: Preview: DataObjectManager module Link to this post

    UncleCheese the issue is not with the Page class itself. Make a subclass of Page (say Page2). No need to add any db field or relationship for that class. Now when you try to add a Resource object to a Page2 class page, the resource will not stick to that page. PageID is set to 0. The issue is always related to a subclass of Page.

    Drye we have always had the related dataobjects sortable and it makes no difference.

  • Mr. Matt
    Avatar
    Community Member
    5 Posts

    Re: Preview: DataObjectManager module Link to this post

    Its where you have a page two levels down from the root in the menu structure:

    Brands :: Works fine
    Brands -> Gucci :: Works Fine
    Brands -> Gucci -> Watch :: Stops working here

    So if you look at the attachment its at the Watch level where commenting out that line fixes the issue

    Attached Files
  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    Well I don't have any pages 3 levels deep using the DataObjectManager. But all of my 1 and 2 level Page subclasses seem to work. They each have there own data and do not display the data of other pages.

    UncleCheese good luck with this one, I'm afraid I can offer no more.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hey, guys, I've fixed this bug. For those of you who hacked the code, please revert your changes and check out the new version to avoid conflicts in the future.

    The problem was that FileDataObjectManager was erroneously using the controller to create the $ownerID field. It introspectively searches the has_many array of the controller class to find the relation name. Most of the time, the controller is passed as $this, which creates a problem. Take this example:

    class Page extends SiteTree
    {
    static $has_many = array ('FileObjects' => 'FileObject');
    }

    class FileObject extends DataObject
    {
    static $has_one = array ('Page' => 'Page');
    }

    class SubPage extends Page
    {

    }

    In the SubPage class, the controller $this will return a SubPage object. The has_many array search will return null in this case, so no $ownerID field is ever set.

    The fix was to use the member method ComplexTableField::getParentIDName() to generate this fieldname correctly. It's still necessary to use the setParentClass method in this case, however. It's used in ComplextTableField for exactly this scenario, but it wasn't being taken advantage of since getParentIDName() wasn't being used.

  • sunnyb0y
    Avatar
    Community Member
    1 Post

    Re: Preview: DataObjectManager module Link to this post

    A little off topic..

    Do you have a downloadable example of http://doc.silverstripe.com/doku.php?id=modules:swfuploadfield so I can look at the code. Having a number of issues trying to get this to work - I think if i can see how the working version is setup this will shed some light on where Ive gone wrong.

    I saw this (http://www.silverstripe.org/archive/show/229938#post229938) but it still does not answer my questions. I'm a bit of a noob so its probably simple stuff. Would just like to see how its setup in the php file / front end.

  • Amir Mostofi
    Avatar
    Community Member
    59 Posts

    Re: Preview: DataObjectManager module Link to this post

    When adding file objects, how do you remove the "Upload from my computer" and "Upload ..." button from the pop up? We need to force the user to only import from an existing folder and to avoid confusion, need to completely remove the "Upload from my computer" section above. What should be changed in the code?

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