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...
We're expecting the output to be...
But weirdly, the output order comes out like this...
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
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
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.
See attached for the screenshot showing site map order.
Will do some more searching shortly.
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...
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?
So when child pages from different parents are mashed together, the order conflicts - does that sound possible?
If I look at the database I can see
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?
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?
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):
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...
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?
[ "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?
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!
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.
Hmmm, thanks for that but there are not jobs running - so do child pages from multiple parents display in sitemap order for you?
I can get the parent ID but can't find a way to get the display order for the parent.
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
<?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
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.
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.
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.
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.
The PageList isn't really meant for showing things nested, where the Auto Nav block is.
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).
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?
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
Would still love to know how to do this is anyone knows
I'm having this exact issue in version 8.5.2. Anyone every come up with this answer?
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.
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.
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.
I added the code in the specific PageList template where i was trying to achieve this.
Hope this helps someone!
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!
Can you post any screenshots?