Sorting page lists with multiple levels

Permalink
Hi All,

I have a page structure something like this...

Rock gods (this page has the page list on it)
- Guitarists
-- Jimi Hendrix
-- Van Halen
- Bassists
-- Flea
-- Steve Harris

I'm using a page list with the "Include all child pages" checked to bring all the pages into a single page list.

The order now goes somewhat randomly, back and forward between the sections...
Jimi Hendrix, Flea, Van Halen, Steve Harris

It seems to order them as "Guitar, Bass, Guitar, Bass" and so on. What I really want it to do is "Guitar, Guitar, Bass, Bass".

In other words I need it to list all the sub-pages from the first child, then all the sub-pages from the next child.

The way this is implemented it's not an option to use 2 Page lists (I have a custom template that needs everything ins a single block).

Any ideas on how I might do this please?

Thanks in advance :)

Sadu
 
jordanlev replied on at Permalink Best Answer Reply
jordanlev
The order it's returning isn't exactly random... rather it is sorting by the sort order of each page -- but the sort order is relative to the parent page. So you're getting this:
1) first page in one section
2) first page in another section
3) first page in a subsection
4) first page in another subsection
5) second page in one section
6) second page in another section
7) second page in a subsection
8) second page in another subsection
9) third page in one section
...etc. etc.


In order to straighten this all out, you'd need to get the parent id of each page and figure out the page order of the parents, then stick the sub-pages in order inside each parent (like in your own array that you construct in php code after you've retrieved the list of pages). If you know you will only have 1 or 2 levels, this shouldn't be too difficult. But if you might have a variable number of levels then it gets real tricky.

You might want to use the autonav block instead in this case, since it will put the returned pages in the proper order (all pages in one section before moving on to the pages of another section).
Sadu replied on at Permalink Reply
Sadu
Thanks for the reply.

I managed to get this working by adding some sorting code into my custom template view.

Cheers.