Hi im trying to get the sitetree to show inside the dataobjectmanager popup, heres what im hoping to achieve
1) upload a set of images
2) apply captions and titles to each
3) add an internal link that echos out on page inside a span. (like a "read more")
1) and 2) are no problem, working great, applying the sitetree however is giving me grief, this is what i have..
My Class file:
<?php
class HomepageImageResource extends DataObject
{
static $db = array (
'HomepageTitle' => 'Text',
'HomepageCaption' => 'Text'
);
static $has_one = array (
'HomepageAttachment' => 'Image',
'HomepageInternalLink' => "SiteTree"
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('HomepageTitle'),
new TextareaField('HomepageCaption'),
new FileIFrameField('HomepageAttachment')
// new SimpleTreeDropdownField( 'HomepageInternalLinkID', 'HomepageInternalLink', 'SiteTree' )
);
}
}
now onto my HomePage extends Page: (note the "// this causes me the error" comment) without that line all works ok but no sitetree
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
static $has_many = array (
'HomepageImages' => 'HomePageImageResource'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root.Content.Main', 'Content');
$fields = parent::getCMSFields();
$homepagemanager = new ImageDataObjectManager(
$this, // Controller
'HomepageImages',
'HomepageImageResource',
'HomepageAttachment',
'HomepageInternalLink', // this causes me the error"
array(
'HomepageTitle' => 'HomepageTitle',
'HomepageCaption' => 'HomepageCaption'
), // Headings
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.Content.Main",$homepagemanager);
$fields->removeFieldFromTab('Root.Content.Main', 'MainPageContent');
return $fields;
}
}
UPDATE: Marked as Solved
this is what i needed to do to get it working if anyone else comes across this issue:
In HomePage.php i changed the getCMSFields() function to:
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root.Content.Main', 'Content');
$fields = parent::getCMSFields();
$homepagemanager = new ImageDataObjectManager(
$this, // Controller
'HomepageImages', // Source name
'HomepageImageResource', // Source class
'HomepageAttachment', // File name on DataObject
//'HomepageInternalLink',
array(
'HomepageTitle' => 'HomepageTitle',
'HomepageCaption' => 'HomepageCaption'
),
'getCMSFields_forPopup'
);
$homepagemanager->setRelationAutoSetting(false);
$fields->addFieldToTab("Root.Content.Main",$homepagemanager);
$fields->removeFieldFromTab('Root.Content.Main', 'MainPageContent');
return $fields;
}
overriding default setRelationAutoSetting to false