I have a Parent -> Child -> Grandchild relationship that look a bit like this
'Menu' has many 'Courses' and 'Meals'
'Course' has many 'Meals' and belongs to many 'Menus'
'Meal' belongs to many 'Courses' and 'Menus'
class Menu extends Page {
private static $many_many = array(
'Courses' => 'Course',
'Meals' => 'Meal'
);
...
}
class Course extends DataObject {
private static $belongs_many_many = array(
'Menus' => 'Menu'
);
private static $many_many = array(
'Meals' => 'Meal'
);
...
}
class Meal extends DataObject {
private static $belongs_many_many = array(
'Menus' => 'Menu',
'Courses' => 'Course'
);
...
In the Menu.ss page template I loop through 'Courses' and within that, I loop through Meals.
This gives me the correct courses associated to the menu, the correct meals associated to the course, but ignores the meals relationship to the menu.
How do I get the correct meals associated to the course and menu?