Accessing jcr:content property from cq:page | Community
Skip to main content
TheBigRed
Level 4
August 12, 2016
Solved

Accessing jcr:content property from cq:page

  • August 12, 2016
  • 4 replies
  • 5386 views

I have a page where I want to access a node property from that page's jcr:content node

How can I do this? I remember seeing an example using the CQ tag or slightly

An example would be greatly appreciated.

Thanks!

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 TheBigRed

I figured it out, its done like this:

 

<%@include file="/libs/foundation/global.jsp"%>
<%
    String title = properties.get("html", "default title");
%>
<%=title%>

4 replies

smacdonald2008
Level 10
August 12, 2016

A page node under /content only holds markup - like HTL/HTML/JSP. 

To access any node property - you have to use an API like the JCR API. 

For example: 

node.getProperty();

To learn how to use JCR API to access a node prop - see: 

https://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html

Hope this helps. 

smacdonald2008
Level 10
August 12, 2016

Take a look at this doc topic:

https://docs.adobe.com/docs/en/cq/5-6-1/developing/pageinfo.html

It talks about an API you can use to get page information. I have never used that API myself - but it may help you get page info without using a lower level API like JCR API. 

TheBigRed
TheBigRedAuthor
Level 4
August 12, 2016

not the page node, the property within the jcr:content of the page node is what I want to access

/content/MyPage/jcr:content <-- this

I want to access that node from the page...not using any java methods or anything.

I did it before but just can't find the documentation.

TheBigRed
TheBigRedAuthorAccepted solution
Level 4
August 12, 2016

I figured it out, its done like this:

 

<%@include file="/libs/foundation/global.jsp"%>
<%
    String title = properties.get("html", "default title");
%>
<%=title%>