querybuilder order by default node order | Community
Skip to main content
Level 2
October 16, 2015
Solved

querybuilder order by default node order

  • October 16, 2015
  • 7 replies
  • 10040 views

Hi,

Is there a possibility for query builder to order by the default order in site admin (default node order), so when I drag the page to change its order in the site admin, my query builder results would retrieve it by the new order. This is the query builder I used: http://docs.adobe.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.html, however, if I didn't input the orderby parameter, it is automatically sorted by either created date or modified date, but what I need to achieve is the node order in the tree. Appreciate your help, thanks.

 

Regards,

Alvin

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

QueryBuilder Debugger does not support it because usually you don't have a search when you want the node order. can simply use navigational access (node.getNodes()) in case you want node order.

7 replies

alvin_lAuthor
Level 2
October 16, 2015

Thanks Sham HC , I have changed to used node.getNodes().

And thanks Mshajiahmed for your reply.

alvin_lAuthor
Level 2
October 16, 2015

Hi,

I tried with @path and @jcr:path, both didn't work as well. Basically if I removed the orderby=@path, the order of the results remained unchanged.

For example if I used the geometrixx site, for example with the following query in the querydebugger:

type=cq:Page
path=/content/geometrixx
property=jcr:content/cq:template
property.value=/apps/geometrixx/templates/homepage
orderby=@path

This will give me the following results:

But actually if I look at my /siteadmin, the order of the geometrixx content is en, fr, de, es, it, ja, zh. So I am wondering whether it is possible to follow the default order of en, fr, de, es, it, ja, zh, client's requirement is if they drag the "zh" to in front of "en" in the siteadmin, my order must be reflecting that as well.

 

Thanks,

Alvin

Community Advisor
October 16, 2015

Try your query in query debugger before you put into code. I tried following code in querydebugger, it does work

http://localhost:4502/libs/cq/search/content/querydebug.html

type=cq:Page
path=/content/geometrixx
property=jcr:content/cq:template
property.value=/apps/geometrixx/templates/homepage
orderby=@path
 

If @path doesn't work try @jcr:path

 

You might have to do a little tweek to your query in order to work. 

Anmol_Bhardwaj
Community Advisor
Community Advisor
May 6, 2022

orderby=@jcr:path works for me. Gives results according to the order in the tree. Same as node.getNodes().

alvin_lAuthor
Level 2
October 16, 2015

Hi,

thanks a lot for your reply. I tried but it didn't work, do I need to specifically stored the path attribute into the child page's node's property?

This is my code: 
            Map<String, String> queryMap = new HashMap<String, String>();
            queryMap.put("type", "cq:Page");
            queryMap.put("path", requestedPage.getPath());
            queryMap.put("1_property", "jcr:content/cq:template");
            queryMap.put("1_property.value", "xxxxxxx");
            queryMap.put("orderby", "@path");
            //queryMap.put("orderby.sort", "asc");

requestedPage is my Parent Page which I perform the search for its child page.

 

Thanks,

Alvin

Community Advisor
October 16, 2015

If you need to order, you have put the order by clause. Following will sort by node path(tree)

orderby=@path

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015

QueryBuilder Debugger does not support it because usually you don't have a search when you want the node order. can simply use navigational access (node.getNodes()) in case you want node order.

October 12, 2020
Does this issue with query builder debugger still exists ? or is it fixed with newer AEM versions?
October 12, 2020

.