Display Navigation Title of child pages in Sightly | Adobe Higher Education
Skip to main content
Level 7
April 1, 2024
解決済み

Display Navigation Title of child pages in Sightly

  • April 1, 2024
  • 2 の返信
  • 1031 ビュー

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>

 

 

このトピックへの返信は締め切られました。
ベストアンサー 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 の返信

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

Mahesh_Gunaje作成者
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.