In my template I'm looping my child pages as 2 separate lists and then their grandchild pages under these. But I want these greatgrandchild pages to be sorted as an entire list and not divided / grouped by their parents. Simply loop after loop does not work as all greatgrandchild pages should be put in order and not grouped by parent then sorted.
I know this could be done by a function to get all the greatgrandchildpages and sort them by a chosen method (e.g. alphabetically). But I don't want to get ALL of them as I need them just the grandchildren for each child.
PAGE - to show list
Child - List Heading
GrandChild - not shown in list
GreatGrandChild - Listed and ALL sorted Alphabetically
On Page you can get the IDs of all children (which are parents of the grand children) using getIDList():
Now you can get all Pages (or whatever pagetype you want) by ParentID:
Same for grand-grandchildren....
You can sort this DataList by whatever you want, e.g.
edit:
$this->Children() does return an ArrayList, not a DataList, so we have to get all children manually. Be aware, this doesn't respect
canView()
, so we get all pages, if the current user has permissions or not. For a simple website this should be ok.Using
$this->Children()->column('ID')
you get the filtered result.A ready to use method could be:
And in your template: