Hi,
I've got a promotional box on my website and I want to have the ability to select a site from the SiteTree through the backend, where the user will be forwarded to, when clicking on the box (image, text and button). It should be very similar to inserting a link, so I tried to use TreeDropdownField.
My code:
class Box extends Page {
static $db = array();
static $has_one = array(
'Photo' => 'Image',
'TargetContent' => 'SiteTree'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TreeDropdownField("TargetContentID", "Choose a site to be forwarded to:", "SiteTree"));
$fields->addFieldToTab("Root.Content.Photo", new ImageField('Photo'));
return $fields;
}
}
class Box_Controller extends Page_Controller {}
Now I already get the correct page ID, but no idea how to handle this :-?
How do I get the URL of the page ID now and how can I filter the SiteTree that will be displayed in the dropdown?
Thanks for any help in advance!
Cheers, Mario