Skip to main content
JonMaguire
Level 3
September 9, 2020
해결됨

Get Subtitle Page Property with HTL

  • September 9, 2020
  • 7 답변들
  • 3127 조회

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?

이 주제는 답변이 닫혔습니다.
최고의 답변: 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>

 

 

 

7 답변

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
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
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
JonMaguire작성자
Level 3
September 10, 2020
This should be the accepted answer.