Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Inherited pages -- sub-class does not save the right Page ID


Reply


7 Posts   942 Views

Avatar
dynamite

Community Member, 66 Posts

13 November 2009 at 6:22pm

I know this has been discussed before, but cannot find it for the life of me!

I have ImageDataObjectManager working on Pages but the "PageID" does not get set when upload a new image in the sub-class pages.

Any help would be great!

Jeremy

Avatar
UncleCheese

Forum Moderator, 4096 Posts

14 November 2009 at 3:04am

You have to use setParentClass("ParentClass");

The problem is that the DOM gets passed $this as the controller, so on subclasses, it gets passed an object that does not have the foreign key, so you need to be explicit. Same is true for CTFs.

Avatar
dynamite

Community Member, 66 Posts

14 November 2009 at 3:08am

Thank you! I knew what the problem was, just couldn't find the function name.

Avatar
dynamite

Community Member, 66 Posts

16 November 2009 at 6:04pm

I am having a difficult time getting this to work -- I assume that this command should be run in the "getCMSFields" method. What I am missing?

Here is a sample of what I have in code/Page.php:

function getCMSFields()
{
$fields = parent::getCMSFields();
   
$manager = new ImageDataObjectManager(
....
$manager->setParentClass('Page');

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

Thank you!

Jeremy

Avatar
UncleCheese

Forum Moderator, 4096 Posts

16 November 2009 at 6:17pm

That looks right to me. What's not working?

Avatar
dynamite

Community Member, 66 Posts

17 November 2009 at 1:55am

Dang, I feel so stupid. I was using an old(er) version of DOM.

But I do have a little problem now - when clicking "Add New ...." or when clicking to edit an existing image, the pop-up doesn't open. Instead the form takes over the whole page.

I tried it 325 and 323 with the same results, and on Firefox and Safari. There were no JS errors in the Firefox Error Console.

What am I doing wrong now? :-)

Jeremy

Avatar
UncleCheese

Forum Moderator, 4096 Posts

17 November 2009 at 2:07am

Some kind of javascript error. I would check Firebug. Make sure the directory for the module is named "dataobject_manager" and not "dataobject_manager_r123" or whatever Silverstripe names it. That path has to be correct to get the JS assets.