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


Reply


7 Posts   1175 Views

Avatar
dendeffe

Community Member, 135 Posts

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?

Avatar
mirkosassetti

Community Member, 20 Posts

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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

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

Avatar
Wilson

Community Member, 63 Posts

29 January 2011 at 9:42am

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.

Thanks!
Wilson

Avatar
dendeffe

Community Member, 135 Posts

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.

Avatar
mirkosassetti

Community Member, 20 Posts

10 February 2011 at 5:35am

Edited: 10/02/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.

Avatar
dendeffe

Community Member, 135 Posts

14 February 2011 at 10:06pm

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: http://pastie.org/1561922