Page List: How to get child pages from multiple parents displaying in sitemap order?

Permalink
C5.6

Hi There,

We have a page list block that is set to list child pages under the Grandparent in site map order like this...
Grandparent
|_Parent A (attribute set to ignore)
  |_Child A1
  |_Child A2
|_Parent B (attribute set to ignore)
  |_Child B1
  |_Child B2

We're expecting the output to be...
Child A1
Child A2
Child B1
Child B2

But weirdly, the output order comes out like this...
Child B1
Child A1
Child A2
Child B2

Looking at this discussion:https://www.concrete5.org/community/forums/customizing_c5/page-list-...

It looks like this feature was already added to the core - is that right?

Does anyone know what I might be doing wrong?

Cheers

Ben

 
ob7dev replied on at Permalink Reply
ob7dev
Not sure why it wouldn't list in site map order if its set to sort that way. The page_list has an api so you can programatically create them outside the page_list block itself:http://documentation.concrete5.org/api/class-Concrete.Core.Page.Pag...

Can you post any screenshots?
cmscss replied on at Permalink Reply 1 Attachment
Thanks for the reply, just a note that this is for 5.6, not 5.7.

See attached for the screenshot showing site map order.

Will do some more searching shortly.
ob7dev replied on at Permalink Reply
ob7dev
Crap, I've never used 5.6 before so I have no clue what I'm talking about when it come's to that version...
cmscss replied on at Permalink Reply
I wonder if child pages get assigned a number for display order within each parent?

So when child pages from different parents are mashed together, the order conflicts - does that sound possible?
cmscss replied on at Permalink Reply
If I look at the database I can see
cDisplayOrder

Just having trouble comparing the child pages to see if that's what the issue is. If so, would there be a way to somehow use the parent order to fix the child order?
cmscss replied on at Permalink Reply
OK, so if I var_dump $page in the page list template, I can see the following for the first child page within each parent (A1 and B1 in the example above):
[
"cDisplayOrder"]=>
  string(1) "0"

I'm guessing this is the issue. I can see that there's $pl->filterByParentID($cParentID) here:
http://legacy-documentation.concrete5.org/developers/pages/searchin...
$pl->filterByParentID($cParentID)

But my php is fairly limited sorry (I'm a designer), is there a way to get the display order for each parent and use it to sort the page list results?

Also can $pl->filterByParentID($cParentID) be used in a block template?
ob7dev replied on at Permalink Reply
ob7dev
Basically any code built into concrete5 can be used in your own blocks. It's the best CMS in the world as far I know.... sorry I can't be of any more help with 5.6. I wasn't around back before 5.7, I'm just the new kid on the block. Maybe one of the c5 legends from around here will drop in and be able to help out a little more than I... but it seems that your atleast on the right track!
tallacman replied on at Permalink Reply
tallacman
I had an issue similar to this a while back and it was related to a job that was stuck running. I reset the jobs and then re-ran them and everything worked fine.
cmscss replied on at Permalink Reply
Hmmm, thanks for that but there are not jobs running - so do child pages from multiple parents display in sitemap order for you?
cmscss replied on at Permalink Reply
I can get the parent ID but can't find a way to get the display order for the parent.
<?php
    $parent = page::getByID($page->getCollectionParentID());
    $parentOrder = $parent->getDisplayOrder();
?>

I also can't find where these sorts of functions might be located in the core block - any help or suggestions would be much appreciated (and just a reminder that my php is very limited!).

Cheers

Ben
hutman replied on at Permalink Reply
hutman
I know I'm chiming in really late on this, but is there a reason you are using the PageList instead of the AutoNav? AutoNav would do what you are looking for I believe.
cmscss replied on at Permalink Reply 1 Attachment
Thanks for the reply, I guess the simple answer is that it isn't a nav.

We're also pulling images, custom page attributes as well as blocks from the pages in the list to create a quick shop item that uses a js overlay with tabs etc (see second state in screenshot attached).

Page List seems like the logical choice - right? Or can Autonav do all that as well? It's a very complicated template so hopefully, it's not too much work to transfer to Autonav.
hutman replied on at Permalink Reply
hutman
By default the AutoNav block outputs things into an unordered list, but it can display anything you want just like the Page List with a Custom Template.

The PageList isn't really meant for showing things nested, where the Auto Nav block is.
cmscss replied on at Permalink Reply
Thanks for that, it makes sense. I guess the issue is that 90% of the items aren't listed, it's just this one section so making a different block template is a bit painful (and expensive for the client).
cmscss replied on at Permalink Reply
As a sanity check, I removed the custom template but the order was the same so I assume this is because of the page list block itself - can anyone confirm this?
cmscss replied on at Permalink Best Answer Reply
Hacked it by tweaking the dates on the pages to get the correct order then sorting by date.

Would still love to know how to do this is anyone knows
stewblack23 replied on at Permalink Reply
stewblack23
I'm having this exact issue in version 8.5.2. Anyone every come up with this answer?
blinkdesign replied on at Permalink Reply
blinkdesign
I had the same issue with 8.5.2.
I added for each page a pagelist block. I know that's not the best way, but it worked for the couple pages I had.
DeanZL replied on at Permalink Reply
Almost a year old i see but perhaps it is still of use to someone. I ran into the same issue and solved it by sorting on the parent elements first and if those are the same sort on the sub level. See snippet.

usort($pages, function($a, $b){
        $parentA = \Concrete\Core\Page\Page::getByID($a->cParentID);
        $parentB = \Concrete\Core\Page\Page::getByID($b->cParentID);
        $compareParent = $parentA->getCollectionDisplayOrder() - $parentB->getCollectionDisplayOrder();
        if ($compareParent === 0) {
            return $a->getCollectionDisplayOrder() - $b->getCollectionDisplayOrder();
        }
        return $compareParent;
    });
    ?>


I added the code in the specific PageList template where i was trying to achieve this.

Hope this helps someone!