Query - List only one level of child pages | Community
Skip to main content
Level 3
November 22, 2021
Solved

Query - List only one level of child pages

  • November 22, 2021
  • 1 reply
  • 1212 views

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? 

 

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 Siva_Sogalapalli

@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.flat=true

 

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  

1 reply

Siva_Sogalapalli
Community Advisor
Siva_SogalapalliCommunity AdvisorAccepted solution
Community Advisor
November 22, 2021

@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.flat=true

 

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  

SonuR1Author
Level 3
November 22, 2021

thanks it worked 🙂