Expand my Community achievements bar.

SOLVED

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

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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.

View solution in original post

3 Replies

Avatar

Level 7

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

Avatar

Correct answer by
Employee Advisor

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.

Avatar

Level 1

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