Hey guys,
I've hit a bit of a problem with a site I'm developing.
I have a DataObject called Staff that is managed via StaffPage (holds information on each member of staff; name, role, description, headshot, email address), outputting to the StaffPage is easy. However I'm wanting to be able to use the same information in the site's NewsPage and ArticlePage as the Author information - so at the end of each NewsPage/ArticlePage you get a wee bit of blurb about the writer.
I've been trying for most of the day to get this to work and I've managed to get a dropdown loaded up in the CMS (thanks to ssbits.com's dropdown population tutorial), however it wont save the information across - and I'm not convinced I've done it right anyway...
Here is the code in NewsPage:
<?php
/**
* Defines the NewsPage page type
*/
class NewsPage extends Page {
static $db = array(
'Date' => 'Date'
);
static $has_one = array(
'Staff' => 'Staff'
);
static $many_many = array(
);
function getMyObjectOptions()
{
if($Pages = DataObject::get('Staff'))
{
return $Pages->map('ID', 'StaffName', 'Please Select');
}
else
{
return array('No Staff found');
}
}
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new DatePickerField('Date', 'Date'));
$fields->addFieldToTab("Root.Content.Main", new DropdownField(
'Staff',
'Please choose a Staff Member',
$this->getMyObjectOptions()
));
return $fields;
}
}
class NewsPage_Controller extends Page_Controller {
}
Presumably someone has done this before, I'm just stuck at this point.
Thanks,
Stewart