how to get all pages under some path(/content/test/test1) in cq5 | Community
Skip to main content
Level 2
October 16, 2015
Solved

how to get all pages under some path(/content/test/test1) in cq5

  • October 16, 2015
  • 3 replies
  • 51244 views

Hi,

I have a requirement where i need to list all html pages under /content/test/test1 (title and url), How to achieve this?

I tried using json query builder but it is giving only few urls not all, please find below the json query.

type=cq:Page
group.p.or=true
group.1_path=/content/test/test1

Thanks

Srinivasula Reddy

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 joerghoh

private void recursePages (Page rootpage)
  Iterator<Page> iter = rootpage.listChildren();
  while (iter.hasNext) {
    final Page child = iter.next();
    if (child.hasChildren) {
      recursePage (child);
    }
    String pageTitle = child.getTitle();
    String resourcePath = child.getPath();

  }
}

recursePage (resourceResolver.get("/content/test/test1).adaptTo(Page.class);
 

Please see the API of the Page class for this.

3 replies

Ojjis
Level 7
October 16, 2015

Hi, the limit (standard) is 10. You can increase this with the parameter "p.limit"
so to get 20 results you could write:

p.limit = 20

 

/Johan

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

private void recursePages (Page rootpage)
  Iterator<Page> iter = rootpage.listChildren();
  while (iter.hasNext) {
    final Page child = iter.next();
    if (child.hasChildren) {
      recursePage (child);
    }
    String pageTitle = child.getTitle();
    String resourcePath = child.getPath();

  }
}

recursePage (resourceResolver.get("/content/test/test1).adaptTo(Page.class);
 

Please see the API of the Page class for this.

Subba_Rao_Adavi
October 16, 2015

you can use p.limit= -1 that will show entire query result.