Just wondering how to display a bi-dimensional DataObjectSet in a template:
In the Page model I have this method:
public function getGroups() {
....if (null === $this->groups) {
........$groups = DataObject::get('MyGroup', 'ParentID = ' . $this->ID, 'Sort', '');
........if ($groups) {
............foreach($groups as $group) {
................$items = DataObject::get('MyItem', "ParentID = {$group->ID}", 'Sort', '');
................if ($items) {
....................if (null === $this->groups) {
........................$this->groups = new DataObjectSet();
....................}
....................$this->groups->push($items);
................}
............}
........}
....}
....return $this->groups;
}
How do I cycle the data to show Groups and Items ?
<% if Groups %>
....<% control Groups %>
........Group name: $Name
........<% control ???? %>
............Item name: ????
........<% end_control %>
....<% end_control %>
<% end_if %>
thank you