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

Image/DO on multiuple pages


7 Posts   1140 Views


28 January 2011 at 11:32pm Community Member, 135 Posts

I often struggle with what Marijn describes here:

A client adds images (as a DO) to a page, when he wants to add the same image from storage, it will disappear on the page it was originally added to.

At the moment, to avoid mistakes, I sometimes just disable the storage part of the DOM-window. But there must be better ways to handle this.

How do you handle this? Am I missing something obvious?


29 January 2011 at 12:40am Community Member, 20 Posts

I ran into this problem frequently and recently I have investigated a lot to understand why it happens by going to browse the code of core classes. This not happen only with DOM, but also with standard classes and single images.
Did you extend the Image class? Different pages use different extended classes of Image?
What I think I've found is that when you select an image from the store, the class of the image is written in the field ClassName of the table File. So, for example, if you used an image on a page that is of class MyImage_Image and you try to use the same image on another page with class MyImage2_Image, the field ClassName in table File change from MyImage_Image to MyImage2_Image. I believe this can then remove the image from the first page because there is no correspondence of the image class.
I hope that the solution is not to extend the Image class, which is not strictly necessary, or at least extend it only once and use that class anywhere, but I have not yet had the opportunity to prove whether this works or not.

Hope this help (and is understandable, my english isn't very good).


29 January 2011 at 8:42am 4085 Posts

It sounds like you guys want a ManyManyFileDOM if you have images that are associated with multiple pages, right? FileDOM and ImageDOM are for has_many relations, but what you're describing are many_many relations..

SilverStripe tips, tutorials, screencasts and more:


29 January 2011 at 9:42am Community Member, 63 Posts

Hi UncleCheese,

Is ManyManyFileDOM the fix for the 'Choose Existing' functionality bug as well?

Apologies, I know I've posted a similar question in another thread, but for this current project I'm just trying to determine whether I should hide 'Choose Existing' or dig into the code, or whether someone else is further ahead. Obviously, you, and a few of the other devs have a better grasp of what's going on with that issue.



1 February 2011 at 3:20am Community Member, 135 Posts

Where can I find some good, basic manymany and filemanymany code examples? I always get confused setting those up.


10 February 2011 at 5:35am (Last edited: 10 February 2011 5:37am), Community Member, 20 Posts

mmm ... maybe the problem is the many_many vs has_many, but i'm not sure.
When i say extended classes of Image i mean something like

class MyImage extend Image

usually done for custom resizing functions.

I tested my theory on a recent site i made, [url][/url] and seems to work. This site have various galleries and various translations that shares the same images without problems ... at least for now, but I still do some more tests.


14 February 2011 at 10:06pm Community Member, 135 Posts

It's weird, because this code seems to working properly. Must find out what's different on that other site, where it is not working: