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

Get Subtitle Page Property with HTL

JonMaguire
Level 2
Level 2

I'm wanting to retrieve the page subtitle and description using HTL. Using the AEM HTL Read–Eval–Print Loop environment to test, I'm able to get the description using ${item.description} but cannot get subtitle using the same format, ${item.subtitle}. Is there a different way to get the subtitle property?

1 Accepted Solution
ChitraMadan
Correct answer by
Community Advisor
Community Advisor

Hi @JonMaguire ,

 

If your page has title and subtitle as shown below, it can be retrieved as:

 

Screenshot 2020-09-09 at 21.47.03.png

 

<ul data-sly-list="${currentPage.listChildren}">
<li>${item.title}</li>
<li>${item.properties.subtitle}</li>
</ul>

 

ChitraMadan_0-1599685547860.png

 

 

View solution in original post

7 Replies
Jörg_Hoh
Employee
Employee

This works because the page resource (more exactly: the jcr:content resource) does have a property named "description". If you add a property called "subtitle", you can also reference this in HTL via ${item.subtitle}.

JonMaguire
Level 2
Level 2
I don't know why this was marked as accepted. @ChitraMadan's answer below should be the accepted solution. ${item.subtitle} does not work. ${item.properties.subtitle} does work.
Vijayalakshmi_S
Community Advisor
Community Advisor

Hi @JonMaguire,

In your snippet, if "item" is a Page object, then item.subtitle won't work as there is no getter exposed/available for the property subtitle in Page API(com.day.cq.wcm.api.Page)

You can retrieve the same using Resource API as ${resource.valueMap.subtitle}

ChitraMadan
Correct answer by
Community Advisor
Community Advisor

Hi @JonMaguire ,

 

If your page has title and subtitle as shown below, it can be retrieved as:

 

Screenshot 2020-09-09 at 21.47.03.png

 

<ul data-sly-list="${currentPage.listChildren}">
<li>${item.title}</li>
<li>${item.properties.subtitle}</li>
</ul>

 

ChitraMadan_0-1599685547860.png

 

 

View solution in original post

kautuk_sahni
Community Manager
Community Manager
Thank you for pointing me to this. I have marked this answer as correct.