querybuilder order by default node order

alvin_l

15-10-2015

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

Accepted Solutions (1)

Accepted Solutions (1)

Sham_HC

15-10-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.

Answers (6)

Answers (6)

alvin_l

15-10-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

Mshajiahmed

15-10-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. 

alvin_l

15-10-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