7939 Posts in 1472 Topics by 944 members
|Go to End|
28 January 2011 at 11:32pm
I often struggle with what Marijn describes here: http://silverstripe.org/dataobjectmanager-module-forum/show/7010?start=272#post295849
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
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
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.
1 February 2011 at 3:20am
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
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, http://www.dreamersbb.it/ 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.
|Go to Top|