Hi there,
I've knocked up a banner management area using DataObjectManager within SiteConfig (with various hints and tips from this forum) and it works perfectly, or should I say WORKED perfectly until today during some testing. When I go to delete an image it 'deletes' fine from within the DataObjectManager but when I browse to the folder the images are stored in, they are still there. I can only remove them by either manually deleting them from the folder or from within 'Files & Images'.
As adding a DataObjectManager in SiteConfig has proven troublesome, I thought it might be an issue to do with that so I redid the code as a simple BannerPage but the problem still exists.
Here is the code - please help as this is driving me nuts!
<-- Banner2.php -->
<?php
class BannerImage2 extends DataObject
{
static $db = array (
);
static $has_one = array (
'myImage2' => 'Image',
'BannerPage' => 'BannerPage'
);
public function getCMSFields_forPopup()
{
$upload = new ImageUploadField('myImage2', 'Upload Banner Image');
$upload->removeFolderSelection();
$upload->uploadFolder = 'BannerImages2';
return new FieldSet($upload);
}
public function getThumb()
{
if($this->myImage2ID)
return $this->myImage2()->setWidth(400);
else
return '(No Image)';
}
}
<-- BannerPage.php -->
<?php
class BannerPage extends Page {
static $has_many = array(
'Images' => 'BannerImage2'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main","Content");
$fields->addFieldsToTab("Root.Content.Main", new DataObjectManager(
$this,
'Images',
'BannerImage2',
array('Thumbs'=>'Upload Image'),
'getCMSFields_forPopup'
));
return $fields;
}
}
class BannerPage_Controller extends Page_Controller {
}