5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1232 Views |
-
remove image, not delete from folder

14 January 2011 at 2:55am
I let my users chose an image for every page to use as a banner. But when someone has chosed an image from the assets folder, and then want to delete it (removes the banner) instead of just change it, the image is deleted from the folder, and from every other page.
How to just set the database field to zero, and don't remove the image?
/Johan
-
Re: remove image, not delete from folder

16 January 2011 at 4:08am
In 2.4 I at least found no no 'disableFileDelete' kind of option for the ImageField. But if you were to block the FileIframeField.js from the requirements, it would prevent the popup, and just immediately unattach the image, without deleting it (which seems not so bad, since you can always re-attach it if you wish).
So you could maybe extend the ImageField to 'BannerImageField', and override the function iframe() (copy it from the FileIFrame class) and block the FileIframeField.js from loading...
Other options:
- present a simple dropdown of banner names from the
- use a treedropdown
- use a radiogroup with banner-image thumbnailsHope this helps - but I've not needed this before, so others might have far better solutions...
-
Re: remove image, not delete from folder

16 January 2011 at 6:59am
Oh, thanks for more than one solution
I dont understand all of it...can I put the extended class in my mysite/code folder, and just write the function iframe(), like:public function iframe() {
// clear the requirements added by any parent controllers
Requirements::clear();
Requirements::add_i18n_javascript('sapphire/javascript/lang');
Requirements::javascript(THIRDPARTY_DIR . '/prototype/prototype.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
//Requirements::javascript('sapphire/javascript/FileIFrameField.js');
Requirements::css('cms/css/typography.css');
Requirements::css('sapphire/css/FileIFrameField.css');
return $this->renderWith('FileIFrameField');
}You se, I'm not a programmer
-
Re: remove image, not delete from folder

16 January 2011 at 11:40am
mysite/code/BannerImageField.php:
<?php
class BannerImageField extends ImageField {
public function iframe() {
// clear the requirements added by any parent controllers
Requirements::clear();
Requirements::add_i18n_javascript('sapphire/javascript/lang');
Requirements::javascript(THIRDPARTY_DIR . '/prototype/prototype.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
//Requirements::javascript('sapphire/javascript/FileIFrameField.js');
Requirements::css('cms/css/typography.css');
Requirements::css('sapphire/css/FileIFrameField.css');
return $this->renderWith('FileIFrameField');
}
}And in your Pages/Objects getCMSFields():
$imageField = new BannerImageField( ...
works, tested it
| 1232 Views | ||
|
Page:
1
|
Go to Top |

