Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Access PageProperties from a Component + Sightly

patK-ze1xYs
Level 4
Level 4

[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  ?   

desktop_exl_promo_600x100_gdrp.png

1 Accepted Solution
Feike_Visser1
Correct answer by
Employee
Employee

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

${currentPage.getContentResource.getResourceType}

or

${currentPage.contentResource.resourceType}

View solution in original post

0 Replies
sudheeras
Level 1
Level 1

Try below:

${currentPage.title}
${currentPage.path}

 

Cheers,
Sudheera

askdctm
Level 9
Level 9

Hi, 

Not quite sure if this helps, but just pasting it across[it looks like probably there are other two methods available].

There are three methods to access content in AEM WCM:

  • Via the properties object introduced in global.jsp:
    The properties object is an instance of a ValueMap (see Sling API) and contains all properties of the current resource.
    Example: String pageTitle = properties.get("jcr:title", "no title"); used in the rendering script of a page component.
    Example: String paragraphTitle = properties.get("jcr:title", "no title"); used in the rendering script of a standard paragraph component.
  • Via the currentPage object introduced in global.jsp:
    The currentPage object is an instance of a page (see CQ5 API). The page class provides some methods to access content.
    Example: String pageTitle = currentPage.getTitle();
  • Via currentNode object introduced in global.jsp:
    The currentNode object is an instance of a node (see JCR API). The properties of a node can be accessed by the getProperty() method.
    Example: String pageTitle = currentNode.getProperty("jcr:title");
Dinu_Arya
Level 7
Level 7

Hi,

Try this -

${pageProperties['cq:designPath']} <br/>
${pageProperties['jcr:title']} <br/>
${pageProperties['sling:resourceType']} <br/>

Thanks,

AryA.

patK-ze1xYs
Level 4
Level 4

Dinu_Arya wrote...

Hi,

Try this -

${pageProperties['cq:designPath']} <br/>
${pageProperties['jcr:title']} <br/>
${pageProperties['sling:resourceType']} <br/>

Thanks,

AryA.

 

This did not work for me , when I use this on my component.html :(.

I still see the empty strings 

patK-ze1xYs
Level 4
Level 4

sudheeras wrote...

Try below:

${currentPage.title}
${currentPage.path}

 

Cheers,
Sudheera

 

I tried this as well. I am still not able to access these page Properties 

Feike_Visser1
Correct answer by
Employee
Employee

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

${currentPage.getContentResource.getResourceType}

or

${currentPage.contentResource.resourceType}

View solution in original post

patK-ze1xYs
Level 4
Level 4

Feike Visser wrote...

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

${currentPage.getContentResource.getResourceType}

or

${currentPage.contentResource.resourceType}

 

I checked with my colleague its working for him. 

Do I need to install any new hot fix / service pack ? for Sightly to work fine ?

Feike_Visser1
Employee
Employee

This is basic/core functionality of Sightly, no need for add-ons here.

ebin_Aby
Level 3
Level 3

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}

ebin_Aby
Level 3
Level 3

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

ebin_Aby
Level 3
Level 3

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>

carolynr5682886
Level 2
Level 2

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

cmr96960454
Level 2
Level 2

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
Employee
Employee

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

shahidp
Level 2
Level 2

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