Hi Uncle Cheese
I've found that content in the dataobjectmanager is showing on the published page when the page is in staging. For instance if I create a page and publish it, then make an edit, add some images through DOM and save the images are displayed on the published site.
Is there a way to hide the images?
My code is as follows:
ImageBlock.php
<?php
class ImageBlock extends DataObject {
static $db = array(
'ImageBlockTitle' => 'Varchar',
'ImageBlockAltText' => 'Text',
'ImageBlockText' => 'HTMLText'
);
static $has_one = array(
//'ImageBlockLinkPage' => 'SiteTree',
'ImageBlockImage' => 'Image',
'ContentPage' => 'ContentPage',
'SectionPage' => 'SectionPage',
'HomePage' => 'HomePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('ImageBlockTitle','Enter the Title'),
new FileIFrameField('ImageBlockImage'),
new TextField('ImageBlockAltText','Enter the ALT (Roll over) text for the image')//,
//new TextField('ImageBlockText','Enter the link text'),
//new SimpleTreeDropdownField("ImageBlockLinkPageID", "Select the page to link", "SiteTree")
);
}
}
?>
DOM code in Page.php
public static $has_many = array(
'PageImages' => 'ImageBlock',
);
function getCMSFields() {
$fields = parent::getCMSFields();
//Image Block
$ImageBlockmanager = new FileDataObjectManager(
$this, // Controller
'PageImages', // Source name
'ImageBlock', // Source class
'ImageBlockImage', // File name on DataObject
array(
'ImageBlockTitle' => 'ImageBlockTitle',
'ImageBlockAltText' => 'ImageBlockAltText',
//'ImageBlockText' => 'ImageBlockText'
//'ImageBlockLinkPage' => 'ImageBlockLinkPage'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
// If undefined, all types are allowed. Pass with or without a leading "."
$ImageBlockmanager->setAllowedFileTypes(array('jpg','gif'));
// Label for the upload button in the popup
$ImageBlockmanager->setBrowseButtonText("Upload image (jpg or gif only)");
// In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
$ImageBlockmanager->setGridLabelField('ImageBlockTitle');
// Plural form of the objects being managed. Used on the "Add" button.
// If left out, this defaults to [MyObjectName]s
$ImageBlockmanager->setPluralTitle('Page Images');
return $fields;
}
Any suggestions?