SS 2.4.x
Weird title. Here's the easiest way I can explain what I need:
I have a page type called Tour. Extends BaseTour.
A Tour can have many AddOns.
An AddOn is a Tour
Really, think about it like a related page system. But searches for that didn't bring up much.
What we want is when a Tour is open in the CMS, we have a tab for "Tour Addons". This will list all Tours already in the system with checkboxes to select as many as needed. (ManyManyComplexTableField). These Tours should NOT be added via this tab. If a new Tour is needed, it is added as a page in the SiteTree.
The display side of things in the CMS isn't the problem. What I am trying to work out is how to reference the TourAddOn object to Tour and vice versa.
Current code snippets:
Tour
...
// Many to many object relationships
static $many_many = array(
'TourOptions' => 'TourOption',
'TourStyles' => 'TourStyle',
'TourAddOns' => 'TourAddOn'
);
...
function getCMSFields() {
$fields = parent::getCMSFields();
// CMS admin popop for options (option name and one field per currency price)
$tourAddOnsTablefield = new ManyManyComplexTableField(
$this,
'TourAddOns',
'TourAddOn',
array(
// Properties from the Tour object?
),
'getCMSFields_forPopup',
"",
"" //sort
);
$tourAddOnsTablefield->setAddTitle( 'A Tour Add On' );
TourAddOn (whole)
<?php
/**
* Tour Add Ons take existing tours in the system and offer them on other tours.
* So a Tour can have many TourAddOns
* And a TourAddOn can have many Tours
*/
class TourAddOn extends DataObject {
static $has_many = array(
'TourAddOns' => 'Tour'
);
// Many to many object relationships
static $belongs_many_many = array (
'Tours' => 'Tour',
);
}
Any takers? If there's a related pages module or snippet floating around, I think that would be a perfect start. Would consider upgrading to 3.x if needed for this one.