Access PageProperties from a Component + Sightly | Community
Skip to main content
Level 4
October 16, 2015
Solved

Access PageProperties from a Component + Sightly

  • October 16, 2015
  • 18 replies
  • 56456 views

[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.
Best answer by Feike_Visser1

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

${currentPage.getContentResource.getResourceType}

or

${currentPage.contentResource.resourceType}

18 replies

Feike_Visser1
Adobe Employee
Adobe Employee
July 24, 2017

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

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

ebin_Aby
Level 2
July 24, 2017

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>

Feike_Visser1
Adobe Employee
Adobe Employee
July 24, 2017

this feature was added in 6.3

carolynr5682886
Level 2
February 26, 2018

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

Level 2
June 8, 2018

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?

Feike_Visser1
Adobe Employee
Adobe Employee
June 8, 2018

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

Level 2
June 8, 2018

Thank u felike visser..it is working

awesome

shahidp
Level 2
March 18, 2019

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