Hi there,
Looking for some advice.
I want to create a new DataObject called "RelatedContent"
This will take the form of a new tab in the CMS, available from any page, that allows the Admin to add links to related content (pages) within the site.
E.G. If they were editing a page about "Document Translation into Urdu" then they might want to link to Case Study pages that relate to this.
I had planned to create a simple data object along the lines of:
<?php
class RelatedContent extends DataObject {
static $db = array(
'DisplayTitle' => 'Text',
'PageURL' => '???',
);
static $has_one = array(
);
static $default_sort = "DisplayTitle ASC";
}
?>
This would then be invoked in the CMS with:
class Page extends SiteTree {
....
static $has_many = array(
'RelatedContents' => 'RelatedContent'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$RelatedContentsTable = new ComplexTableField($this, 'RelatedContents', 'RelatedContent', array('DisplayTitle'=> 'Show.Link.As', 'PageURL'=> 'Links.To.Page'));
$fields->addFieldToTab('Root.Content.RelatedContent', $RelatedContentsTable);
return $fields;
}
}
However, I want the PageURL component to be a dropdown in the CMS with links to all the pages in the site tree (and not a textbox, so that the clients isnt copy/pasting links)... basically just mimicing thebehaviour when you add a link from the WYSIWYG editor. I know that there is this "TreeMultiselectField" but I can't work out how to use it to achieve this.
Any help appreciated, thank you :)