29 January 2011 at 12:40am
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).
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: http://www.leftandmain.com
29 January 2011 at 9:42am
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.
10 February 2011 at 5:35am
(Last edited: 10 February 2011 5:37am),
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]http://www.dreamersbb.it/[/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.