Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Image/DO on multiuple pages

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1128 Views
  • dendeffe
    Avatar
    Community Member
    135 Posts

    Image/DO on multiuple pages Link to this post

    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?

  • mirkosassetti
    Avatar
    Community Member
    20 Posts

    Re: Image/DO on multiuple pages Link to this post

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image/DO on multiuple pages Link to this post

    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

  • Wilson
    Avatar
    Community Member
    63 Posts

    Re: Image/DO on multiuple pages Link to this post

    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

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: Image/DO on multiuple pages Link to this post

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

  • mirkosassetti
    Avatar
    Community Member
    20 Posts

    Re: Image/DO on multiuple pages Link to this post

    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.

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: Image/DO on multiuple pages Link to this post

    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

    1128 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.