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.

All other Modules

Discuss all other Modules here.

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

Uploadify import image removes image from other page


Go to End
Reply

10 Posts   2344 Views

Avatar
klikhier

12 November 2010 at 1:11am (Last edited: 12 November 2010 1:14am), Community Member, 150 Posts

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'

Avatar
UncleCheese

12 November 2010 at 3:38am 4085 Posts

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

Avatar
klikhier

12 November 2010 at 5:23am Community Member, 150 Posts

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?

Avatar
klikhier

10 March 2011 at 4:11am Community Member, 150 Posts

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.

Avatar
UncleCheese

10 March 2011 at 4:27am 4085 Posts

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.

Avatar
UncleCheese

10 March 2011 at 5:16am 4085 Posts

Found the patch and applied it.

https://github.com/unclecheese/Uploadify

Avatar
klikhier

10 March 2011 at 7:43am (Last edited: 10 March 2011 7:54am), Community Member, 150 Posts

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

Avatar
UncleCheese

10 March 2011 at 8:48am 4085 Posts

Great! Thanks for being the first to test it.

Go to Top