10379 Posts in 2194 Topics by 1710 members
| Go to End | Next > | |
| Author | Topic: | 1844 Views |
-
Uploadify import image removes image from other page

12 November 2010 at 1:11am Last edited: 12 November 2010 1:14am
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' -
Re: Uploadify import image removes image from other page

12 November 2010 at 3:38am
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 -
Re: Uploadify import image removes image from other page

12 November 2010 at 5:23am
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?
-
Re: Uploadify import image removes image from other page

10 March 2011 at 4:11am
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.
-
Re: Uploadify import image removes image from other page

10 March 2011 at 4:27am
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.
-
Re: Uploadify import image removes image from other page

10 March 2011 at 5:16am
Found the patch and applied it.
-
Re: Uploadify import image removes image from other page

10 March 2011 at 7:43am Last edited: 10 March 2011 7:54am
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',' '));
Works like a charm...
-
Re: Uploadify import image removes image from other page

10 March 2011 at 8:48am
Great! Thanks for being the first to test it.
| 1844 Views | ||
| Go to Top | Next > |

