Jump to:

10990 Posts in 2727 Topics by 1818 members

All other Modules

SilverStripe Forums » All other Modules » Uploadify import image removes image from other page

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 2325 Views
  • klikhier
    Avatar
    Community Member
    150 Posts

    Uploadify import image removes image from other page Link to this post

    UncleCheese,

    I ran into the following situation today on SS2.4.2 and the latest Uploadify (I think r510):

    Photo.php

    <?php
    class Photo extends Image {

       static $has_one = array (
          'Page' => 'Page'
       );

    }
    ?>

    Page.php

    ...

       public static $has_many = array(
          'Photos' => 'Photo'
       );

    ...

          $fields->addFieldToTab('Root.Content.'._t('CMS.PHOTOS','Photos'), $miuf = new MultipleImageUploadField('Photos',_t('CMS.CONTENT_PHOTOS','Content photos')));

    ...

    Situation:

    1. In CMS open page 'home' and upload new image using uploadify
    2. Check front-end: image perfectly visible
    3. Back in CMS open page 'about us' and import the same image using 'Choose existing'
    4. Check front-end: image perfectly visible, BUT no longer on page 'home'. Also in CMS the image is gone on page 'home'

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify import image removes image from other page Link to this post

    That's funny. I literally just discovered this bug yesterday, just hours before you posted it.

    Yeah, it's a tricky one. The "choose existing" functionality for a multiple file upload field would have to be based on a many_many rather than a has_many.

    The other solution is to copy the files on import -- like DOM does. That way you don't break any relationships.

    It's a major drag, either way. Neither is a clean solution.

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: Uploadify import image removes image from other page Link to this post

    Ok thanks for you quick response!!!

    What would be the quickest fix. Could you lead me/show me where to find/provide me with the code to copy files like done in DOM?

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: Uploadify import image removes image from other page Link to this post

    Hi Uncle Cheese. Is it possible/ease to setup a multiple file upload field with a many_many relationship or does this involve some serious coding? All this to prevent images disappearing from other pages when adding them (choose existing) to a new page.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify import image removes image from other page Link to this post

    Yes.. thank you for reminding me. There's a patch floating around this forum that updates Uploadify to use many_many..

    If you find it, please post it here.. I'll keep looking. Hopefully whoever wrote it can submit a pull request and we can get that into Github.

  • UncleCheese
    Avatar
    4085 Posts
  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: Uploadify import image removes image from other page Link to this post

    Thanks Uncle Cheese,

    I've set it up like this:

    // mysite/code/Photo.php

    class Photo extends Image {

    static $belongs_many_many = array (
    'Pages' => 'Page'
    );

    }

    // mysite/code/Page.php

    ...

    public static $many_many = array(
    'Photos' => 'Photo'
    );

    ...

    $fields->addFieldToTab("Root.Content.Photos", new MultipleImageUploadField('Photos','&nbsp;'));

    Works like a charm...

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify import image removes image from other page Link to this post

    Great! Thanks for being the first to test it.

    2325 Views
Page: 1 2
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.