Access PageProperties from a Component + Sightly | Community
Skip to main content
Level 4
Oct 16, 2015 2:29 AM UTC
Solved

Access PageProperties from a Component + Sightly

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here. 

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Question:

In JSP I have used (currentPage.getContentResource()).getResourceType() to access resourcetype of a template from a component.

In sightly I wondered if we can access the same using ${pageProperties}

I am trying following from the component.html , and I get empty String Values

${pageProperties.cq:designPath} <br/>

${pageProperties.jcr:title} <br/>

${pageProperties.sling:resourceType} <br/>

How can I do this in Sightly  ?   

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Oct 16, 2015 2:29 AM UTC

If you have this in JSP, you can do it like this in Sightly:

${currentPage.getContentResource.getResourceType}

or

${currentPage.contentResource.resourceType}

18 replies

shahidp
Level 2
Mar 18, 2019 6:53 AM UTC

Hi, Could you please exrplain when to use pageProperties,properties and currentPage .

Translate
Level 2
Jun 8, 2018 11:17 AM UTC

Thank u felike visser..it is working

awesome

Translate
Feike_Visser1
Employee
Jun 8, 2018 9:43 AM UTC

${pageProperties.jcr:description @ context='html'}

Translate
Level 2
Jun 8, 2018 9:31 AM UTC

Actually we can read the page properties in CQ as below.

${pageProperties.jcr:description}

If we enter jcr:description as some html content is page properties. How to read/handle that in sightly?  Any suggestions please?

Translate
carolynr5682886
Level 2
Feb 26, 2018 11:05 PM UTC

What about getting other properties other than the title when using a jsp, such as getting the height?

Translate
Feike_Visser1
Employee
Jul 24, 2017 7:48 PM UTC

this feature was added in 6.3

Translate
ebin_Aby
Level 2
Jul 24, 2017 7:21 PM UTC

Any way we can do it in 6.1 . Was trying by  HTL Block Statements

<div data-sly-use.product=“/etc/commerce/product/12345”>

  ${ product.title }

</div>

Translate
Feike_Visser1
Employee
Jul 24, 2017 6:28 PM UTC

In 6.3 you can access the resource directly via data-sly-use.

Example: htl-examples/button.html at master · heervisscher/htl-examples · GitHub

Translate
ebin_Aby
Level 2
Jul 24, 2017 6:21 PM UTC

How can I access node properties of different nodes? ( not current page, directly by HTL , not by js or java )

Translate
ebin_Aby
Level 2
Jul 24, 2017 6:20 PM UTC

How can I access node properties of different nodes. (directly by HTL , not by js or java )

something like this ?

<div id="data" data-sly-use.tesr="/etc/ttt">

  ${tesr.count}

Translate