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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Query - List only one level of child pages

Avatar

Level 3

I'm trying to write a query to list only one level of child pages but I'm getting the list from all the levels.

below is the query I'm trying, is there a way we can get only one level of child pages. 

 

http://localhost:4502/bin/querybuilder.json?type=cq:Page&path=/content/xyz&orderby=@jcr:title 

 

any quick help? 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@SonuR1  you can add path.flat=true which would list only direct child pages.

 

path.flat=true

If true searches only the direct children . 

 

please try below 

http://localhost:4502/bin/querybuilder.json?type=cq:Page&path=/content/xyz&orderby=@jcr:title&path.f...

 

FYI: https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md 

 

Also, i'm not sure about exact requirement, but you can also try getting direct child pages using API instead of query. 

https://www.tabnine.com/code/java/methods/com.day.cq.wcm.api.Page/listChildren  

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@SonuR1  you can add path.flat=true which would list only direct child pages.

 

path.flat=true

If true searches only the direct children . 

 

please try below 

http://localhost:4502/bin/querybuilder.json?type=cq:Page&path=/content/xyz&orderby=@jcr:title&path.f...

 

FYI: https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md 

 

Also, i'm not sure about exact requirement, but you can also try getting direct child pages using API instead of query. 

https://www.tabnine.com/code/java/methods/com.day.cq.wcm.api.Page/listChildren