Thanks for your reply.
On your site it seems to work as expected :-)
My code is below for one of the category page. I am guessing I have done something wrong.
class AboutUsHolder extends Page {
static $add_action = 'AboutUsHolder';
static $allowed_children = array();
static $has_many = array (
'AboutUsPages' => 'AboutUsPage',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$item = new DataObjectManager( $this, 'AboutUsPages', 'AboutUsPage');
$fields->addFieldToTab('Root.Content.Main', $item);
return $fields;
}
}
class AboutUsPage extends ItemBase {
static $has_one = array (
'Picture' => 'Image',
'AboutUsHolder' => 'AboutUsHolder'
);
static $has_many = array (
'AboutUsItems' => 'AboutUsItem',
);
function getCMSFields() {
$fields = new FieldSet();
$item = new DataObjectManager( $this, 'AboutUsItems', 'AboutUsItem');
$item->setAddTitle('About Us sub article page');
$fields->push($item);
$fields->push(new ImageField('Picture', 'Main Image'));
return $fields;
}
}
class AboutUsItem extends ItemBase {
static $has_one = array(
'AboutUsPage' => 'AboutUsPage',
'Picture' => 'Image'
);
static $has_many = array (
'Images' => 'ItemImageResource'
);
function getCMSFields() {
$fields = new FieldSet();
$fields->push(new ImageField('Picture', 'Picture'));
$manager = new ImageDataObjectManager(
$this, // Controller
'SliderImages', // Source name
'ItemImageResource', // Source class
'Attachment', // File name on DataObject
array(
'Url' => 'Url'
), // Headings
'getCMSFields_forPopup' // Detail fields
// Filter clause
// Sort clause
// Join clause
);
$manager->setParentClass("ItemBase");
$fields->push($manager);
return $fields;
}
}
class ItemImageResource extends DataObject {
static $db = array (
'Url' => 'Text'
);
static $has_one = array (
'Attachment' => 'Image', //Needs to be an image
'ItemBase' => 'ItemBase'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Url'),
new FileIFrameField('Attachment')
);
}
public function canCreate(){
return false;
}
}