Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
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