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?
Solved! Go to Solution.
Views
Replies
Total Likes
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>
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}.
Views
Replies
Total Likes
Views
Replies
Total Likes
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}
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>
Views
Replies
Total Likes
Views
Replies
Total Likes