Hello Team,
Solved! Go to Solution.
Views
Replies
Total Likes
hi @Mahesh_Gunaje,
it's not completely clear what's your question so waiting for your feedback I'll try some guesses.
It sounds like you’re running into the expected behaviour of the out‐of‐the‐box LanguageNavigationImpl: the NavigationItem objects are built based on the current page context, which is why you’re seeing the current page URL instead of what you might expect for the language/country details.
Since you need to show different country/language names (for example, using a “Navigation Title”) when your support page has the property isSpecialPage, one approach is to post-process the list returned by langNavigation.getItems(). In your custom model, you can iterate over each NavigationItem, check the current page for the isSpecialPage flag, and then—if true—fetch the custom titles and URLs from the underlying resource (or via the Page API).
public List<MyCustomLanguageNavigationItem> getCustomItems() { List<NavigationItem> items = langNavigation.getItems(); List<MyCustomLanguageNavigationItem> customItems = new ArrayList<>(); boolean isSpecial = currentPage.getProperties().get("isSpecialPage", false); for (NavigationItem item : items) { String title = item.getTitle(); String url = item.getURL(); if (isSpecial) { // Attempt to adapt the underlying resource to access custom properties ValueMap properties = item.getResource().adaptTo(ValueMap.class); if (properties != null && properties.containsKey("navTitle")) { title = properties.get("navTitle", title); } // Optionally, adjust the URL if needed by resolving the correct page path. } // Create your custom navigation item with the modified title (and optionally URL) customItems.add(new MyCustomLanguageNavigationItem(title, url, item.getChildren())); } return customItems; }
While the out-of-the-box LanguageNavigationImpl provides a good starting point, your scenario requires some custom logic. By post-processing the navigation items to override titles and URLs based on your conditions, you should be able to achieve the desired behaviour.
Hope this helps. Let me know if you need further clarification or run into any issues.
Hi Mahesh,
To retrieve detailed URL information for country and language in your custom language navigation component, you would typically extend the existing functionality provided by AEM's Core Components.
Since you're already using a proxy component with a Sling resource super type of core/wcm/components/languagenavigation/v1/languagenavigation, you need to ensure that your custom method within the Sling model is correctly set up to extract the URL details.
Your custom method getCustomItems() should iterate over the items and fetch the details from the paths. Since you're not finding the URL details directly, consider checking:
hi @Mahesh_Gunaje,
it's not completely clear what's your question so waiting for your feedback I'll try some guesses.
It sounds like you’re running into the expected behaviour of the out‐of‐the‐box LanguageNavigationImpl: the NavigationItem objects are built based on the current page context, which is why you’re seeing the current page URL instead of what you might expect for the language/country details.
Since you need to show different country/language names (for example, using a “Navigation Title”) when your support page has the property isSpecialPage, one approach is to post-process the list returned by langNavigation.getItems(). In your custom model, you can iterate over each NavigationItem, check the current page for the isSpecialPage flag, and then—if true—fetch the custom titles and URLs from the underlying resource (or via the Page API).
public List<MyCustomLanguageNavigationItem> getCustomItems() { List<NavigationItem> items = langNavigation.getItems(); List<MyCustomLanguageNavigationItem> customItems = new ArrayList<>(); boolean isSpecial = currentPage.getProperties().get("isSpecialPage", false); for (NavigationItem item : items) { String title = item.getTitle(); String url = item.getURL(); if (isSpecial) { // Attempt to adapt the underlying resource to access custom properties ValueMap properties = item.getResource().adaptTo(ValueMap.class); if (properties != null && properties.containsKey("navTitle")) { title = properties.get("navTitle", title); } // Optionally, adjust the URL if needed by resolving the correct page path. } // Create your custom navigation item with the modified title (and optionally URL) customItems.add(new MyCustomLanguageNavigationItem(title, url, item.getChildren())); } return customItems; }
While the out-of-the-box LanguageNavigationImpl provides a good starting point, your scenario requires some custom logic. By post-processing the navigation items to override titles and URLs based on your conditions, you should be able to achieve the desired behaviour.
Hope this helps. Let me know if you need further clarification or run into any issues.