Hi
On my "HomePage.php", I'm using the following:
$tablefield = new HasManyComplexTableField(
$this,
'Banners',
'Banner',
array(
'BannerImage' => 'Banner Image',
'BannerText' => 'Banner Text'
),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle( 'Banner' );
$fields->addFieldToTab( 'Root.Content.Banner', $tablefield );
Together with "Banner.php":
<?php
class Banner extends DataObject {
static $db = array(
'BannerText' => 'Varchar(100)'
);
static $has_one = array(
'Page' => 'Page',
'BannerImage' => 'Image'
);
function getCMSFields_forPopup() {
return new FieldSet(
new TextareaField('BannerText'),
new ImageField('BannerImage')
);
}
}
?>
So far so good- everything works. However, I want to display these same items on every page throughout the website. So in "Page.php", I added the following:
public function BannerBox(){
return DataObject::get("Banner");
}
Initially, this seemed OK too, displaying the items throughout the site. Then I realised that the items were being displayed regardless of whether they were enabled (ie regardless of whether the tickbox in the popup was ticked or not). Am I using the correct method to call the data onto each page, or is this a bug?
Many thanks