Skip to main content
JonMaguire
Level 3
September 9, 2020
Solved

Get Subtitle Page Property with HTL

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ChitraMadan
ChitraMadanAccepted solution
Community Advisor
September 9, 2020

Hi @jonmaguire ,

 

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

 

 

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

 

 

 

7 replies

joerghoh
Adobe Employee
Adobe Employee
September 9, 2020

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}.

Translate
JonMaguire
Level 3
September 10, 2020
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.
Translate
Vijayalakshmi_S
Level 10
September 9, 2020

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}

Translate
ChitraMadan
Community Advisor
ChitraMadanCommunity AdvisorAccepted solution
Community Advisor
September 9, 2020

Hi @jonmaguire ,

 

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

 

 

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

 

 

 

Translate
JonMaguire
Level 3
September 10, 2020
This should be the accepted answer.
Translate