user5829212
user5829212

Reputation:

How to Get data from child pages in cq5?

I have to create a parent page which will be overview page. It will have 5 child pages which are detail pages and will contain title and text. I want that my parent page should fetch the title and text from these 5 child pages and display on overview. There will also be a link on parent page which will take it to respective child page. Please help with the implementation.

Upvotes: 0

Views: 1954

Answers (1)

dzenisiy
dzenisiy

Reputation: 865

You may use Page interface:

Iterator<Page> iterator = currentPage.listChildren();
while (iterator.hasNext()) {
    Page childPage = iterator.next();
    ValueMap childProps = childPage.getProperties();
    String title = childProps.get("title", "");
    String text = childProps.get("text", "");
    //output this props values just like you want to
}

Upvotes: 2

Related Questions