I'm working on creating a "Call To Action" sidebar using DOM. The admin can select an button image and a page to link to inside the site. I want this to be available on all pages, so I'm making a 'Page' => 'Page relationship. Inside the SS admin though, when I'm editing a normal "Page" and I click the 'Add [Call To Action]' button, the lightbox popup shows a 404 page. Now, if I'm on a "Redirector" Page and try to add one there, I get the correct file upload page with the Upload files from my computer, Upload Files button, etc.
The 404 url is http://localhost/admin/EditForm/field/CallToActions/upload
Code below
class CallToAction extends DataObject
{
static $db = array (
);
static $has_one = array (
'CTAAttachment' => 'Image',
'Page' => 'Page',
'PageLink' => 'SiteTree'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Address'),
new SimpleTreeDropdownField("LinkID", "Select a page to link to", "SiteTree"),
new ImageField('CTAAttachment', 'CTA Image')
);
}
}
class Page extends SiteTree {
public static $db = array(
'SecondaryNav' => 'Boolean'
);
public static $has_one = array(
);
public static $has_many = array(
'CallToActions' => 'CallToAction'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Behaviour", new CheckboxField("SecondaryNav", "Show In Secondary Menu"));
$manager = new ImageDataObjectManager(
$this, // Controller
'CallToActions', // Source name
'CallToAction', // Source class
'CTAAttachment', // File name on DataObject
array(), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab("Root.Content.CallsToAction",$manager);
return $fields;
}
}