Hi Team,
Need some clarification on orderby in query builder for pages.
I have parent page inside that i have 10 child pages
If not specify any order in Query builder on which order sort will happen ??
If I want to sort on file structure which parameter i need to pass to Query builder.
Need your input here .
Thanks and Regards
Manikantha R
Solved! Go to Solution.
Views
Replies
Total Likes
The order in the result set of a query will only be determined by the order by statement; and you cannot search for the "natural" order in which sibling nodes are ordered.
If you need to need to process the child nodes of a node in their natural order, do not search for the child nodes, but rather their parent; and then iterate the children of the parent node.
Hi,
I think the order is node order in the tree.
what do you mean by file structure order?
If you want to sort with node type
path=/content/aemlab/oneweb/us
orderby=@jcr:primaryType
orderby.sort=desc
p.limit=-1
Hi Arun,
Thanks for your quick reply
Below is screen shot for reference
In we-retail site i need the order in highlighted way.
I tried Query debugger
Its not giving as expected.
Need your help here
The order in the result set of a query will only be determined by the order by statement; and you cannot search for the "natural" order in which sibling nodes are ordered.
If you need to need to process the child nodes of a node in their natural order, do not search for the child nodes, but rather their parent; and then iterate the children of the parent node.
please refer querybuilder_cheatsheet
https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md
Following will sort by node path(tree) orderby = @jcr:path
Ex:
type=cq:Page
path=content/we-retail/us/en/experience
orderby=@jcr:path
But you can simply use navigational access (node.getNodes()) in case you want node order.
Thanks
When the orderby predicate is not specified in the query, the order of results returned is random, and the order in the JCR is not followed.
When you specify the orderby predicate without the sort order, the default ordering is ascending - asc.
Hi Lokesh
Thanks for quick reply
I have tried with below format
type=cq:Page
path=/content/we-retail/us/en/experience/
orderby=@jcr:path
what parameter we need to pass for orderyby to get in like below format
I think for this case you can simply use the page.listChildren() instead of running a query to get child pages, which will give you the order you wanted.
Is there a reason why you've to run a query to get the child pages as in the order of JCR?
Views
Likes
Replies