pageList order not same as sitemap

I am trying to create next prev navigation to will go through all pages in the site.

So I am using this to get the pageList

$pageList = Loader::model('page_list');
$pageList = new PageList();
$pages= $pageList->get();

But the list order is not the same as the sitemap, some child pages are listed on outside of their parents. How do I create the list array in the exact sitemap order, with children listed after their top level?

alternately, is there is a solution for Next/previous that will go from homepage to every page in site?

thanks for your help.

View Replies: View Best Answer
jordanlev replied on at Permalink Best Answer Reply
Unfortunately the page list object is not really set up to handle multiple levels of pages nicely (in fact, it doesn't really handle the sitemap hierarchy at all -- it flattens everything and not in the order you usually want it to be).

I assume what you want is for the "next" link to go to the current page's first child page if children exist, and if not then to go to a sibling page, and then if that doesn't exist go back "up" to the parent's sibling? You could try extracting out the code from the autonav block (which *does* generate a sitemap hierarchy), or maybe even simpler is to just code in the logic outlined above (on each page, look for child pages and link to the first one if it exists, otherwise link to next sibling page if it exists, otherwise link to parent's sibling page if it exists, etc.)

Going to be a huge ordeal any way you slice it -- might be best off just having a block that users place on a page with a manual selection of which page to link to.

frz replied on at Permalink Reply
yup, the page list doesn't honor the tree...

you might start with this block:

and then just hack it to not "go around the bend" when it gets to the last page in a level but instead go up/down or whatever you're thinking for navigating the tree this way.