Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

querybuilder order by default node order

Avatar

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
alvin_l
Level 1

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)

Avatar

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

161 likes

Total Posts

2,114 posts

Correct Reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

161 likes

Total Posts

2,114 posts

Correct Reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile
Sham_HC
Level 10

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)

Avatar

Avatar
Boost 1
Level 1
Ashish-Bhupta
Level 1

Like

1 like

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
Ashish-Bhupta
Level 1

Like

1 like

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
Ashish-Bhupta
Level 1

12-10-2020

.

Avatar

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
alvin_l
Level 1

15-10-2015

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

And thanks Mshajiahmed for your reply.

Avatar

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
alvin_l
Level 1

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

Avatar

Avatar
Validate 25
Level 6
Mshajiahmed
Level 6

Likes

15 likes

Total Posts

331 posts

Correct Reply

126 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 6
Mshajiahmed
Level 6

Likes

15 likes

Total Posts

331 posts

Correct Reply

126 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
Mshajiahmed
Level 6

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. 

Avatar

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
alvin_l
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
alvin_l
Level 1

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

Avatar

Avatar
Validate 25
Level 6
Mshajiahmed
Level 6

Likes

15 likes

Total Posts

331 posts

Correct Reply

126 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 6
Mshajiahmed
Level 6

Likes

15 likes

Total Posts

331 posts

Correct Reply

126 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
Mshajiahmed
Level 6

15-10-2015

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

orderby=@path