First of all, thanks for answering my last post.
I'm building a site for a film distributor, and I'm trying to make a page for their programmes that allows them to associate each program with a number of broadcasters.
I've got a many-many relation between a ProgrammePage (contains content,photos and a list of broadcasters) and Broadcasters page types (just contains a title), and a checkbox field of all the Broadcasters that can be associated with it.
So this all stores fine, but I'm trying to make the layout page for the ProgrammePage display the title of all the broadcasters.
When I had just a 1-1 relationship I could just put the following function my ProgrammePage.php and call it with <% control ReturnBroadcaster %>
function ReturnBroadcaster() {
return DataObject::get_by_id("Broadcaster",$this->BroadcasterID);
}
But now I've got a many-many I believe the relationships are no longer stored in the programmepage table (in programmepage_broadcaster instead I think) and Im a bit stuck as to where I should be pulling out the data from.
So basically my question is how do I list the titles of all the associated objects from a many-many relationship?
My ProgrammePage.php:
static $many_many = array(
'Broadcasters' => 'Broadcaster'
);
...
function getCMSFields() {
...
$categoryList = DataObject::get('Broadcaster');
$fields->addFieldToTab('Root.Content.Broadcasters', new CheckboxSetField('Broadcasters', '', $categoryList));
...
}
My Broadcaster.php:
...
static $many_many = array(
'ProgrammePages' => 'ProgrammePage'
);
..
Thanks for any help you can provide,
chris