Display Navigation Title of child pages in Sightly | Community
Skip to main content
Level 7
April 1, 2024
Solved

Display Navigation Title of child pages in Sightly

  • April 1, 2024
  • 2 replies
  • 1030 views

Hello Everyone,

 

I can display child pages title using the below Sightly code.

 

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

Is it possible to list the Navigation title of child pages using Sightly? Tried below logic, But no luck

 

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

 

 

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 Kamal_Kishor

@mahesh_gunaje : There is no function as navTitle in com.day.cq.wcm.api.Page api.

Please try with: ${item.navigationTitle}

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/api/Page.html#getNavigationTitle--

thanks.

2 replies

Jagadeesh_Prakash
Community Advisor
Community Advisor
April 1, 2024

@mahesh_gunaje  can you try below code 

<div data-sly-use.page="com.day.cq.wcm.api.Page">
<ul data-sly-list.child="${page.listChildren}">
<li>${child.navigationTitle}</li>
</ul>
</div>
 
Kamal_Kishor
Community Advisor
Kamal_KishorCommunity AdvisorAccepted solution
Community Advisor
April 1, 2024

@mahesh_gunaje : There is no function as navTitle in com.day.cq.wcm.api.Page api.

Please try with: ${item.navigationTitle}

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/api/Page.html#getNavigationTitle--

thanks.

Level 7
April 1, 2024

Hi @kamal_kishor 

 

Thanks for the solution. This works.

There is no function as navTitle in com.day.cq.wcm.api.Page api.:  True. Just checked the details.

My query: in the jcr:content, I can see the jcr property as navTitle. So, how come below statement works fine?

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

 

Kamal_Kishor
Community Advisor
Community Advisor
April 1, 2024

@mahesh_gunaje : If you recall, getting page or component values in your HTL/Sightly via sling model (APIs) is by using their getter method name (remove get prefix, and lowercase first letter), so getNavigationTitle becomes navigationTitle.

Usually, you would have seen people naming field values and their getter methods similarly, maybe that's why you felt that way. But as I mentioned earlier, it is based on the getter method name.

In the impl class of your sling model, they would have been getting the value of actual property using their name i.e navTitle

thanks.