Get Subtitle Page Property with HTL | Community
Skip to main content
JonMaguire
Level 3
September 9, 2020
Solved

Get Subtitle Page Property with HTL

  • September 9, 2020
  • 3 replies
  • 2973 views

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

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>

 

 

 

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

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

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>

 

 

 

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