i m working on a piece of cq component, what i need is to retrieve an image filereference path and render the image on the page.
e.g this is my page structure as shows on picture.
say i m current on index page, i know how to retrieve index page's children page and get their value map of jcr:content, and get all the properties out from jcr:content...
but i dont know how to retrieve it's jcr:content/image node-> the image, and how to retrieve it's filereference property...
here is my code, it crashes...
<%
boolean includeTitle = properties.get("includeTitle", false);
boolean includeImage = properties.get("includeImage", false);
boolean includeSubTitle = properties.get("includeSubTitle", false);
boolean includeDescription = properties.get("includeDescription", false);
String type = currentStyle.get("type", "plain");
%>
<%
Iterator<Page> currentPageChildren = currentPage.listChildren();
while(currentPageChildren.hasNext()){
Page childPage = currentPageChildren.next();
ValueMap childPageProperties = childPage.getProperties();
//trying to retrieve the image node
Node imageNode = childPage.getContentResource("image").adaptTo(Node.class);
String childPageTitle = childPageProperties.get("jcr:title", String.class);
String childPageSubTitle = childPageProperties.get("subtitle", String.class);
String childPageDescription = childPageProperties.get("jcr:description", String.class);
%>
<div>
<% if (includeTitle) { %>
<p><%= childPageTitle%></p>
<% }
if (includeSubTitle) { %>
<p><%= childPageSubTitle%></p>
<% }
if (includeDescription) { %>
<p><%= childPageDescription%></p>
<% } %>
//test to print image's filereference path in string on page
<p><%=imageNode.getProperty("fileReference") %></p>
</div>
<%
}
%>
please help me with some code example, thx