0

I'm trying to find out if a Nav Item is selected from a sitemap ADT. When I do so, it always outputs it as false. How can I go about finding out if a navitem is selected from the ADT?

<#list navItems as navItem>
    <#if navItem.isSelected()>
        <p>True</p>
    <#else>
        <p>False</p>
    </#if>
</#list>
Rohit Rajendran
  • 629
  • 9
  • 27

1 Answers1

2

for sitemap template i think you can use the pages variable e check if current page name is equal of page name this way

<#if entries?has_content>
    <#list entries as page>
        <#assign currPageID = themeDisplay.getLayout().getLayoutId()>
        <#assign pageID = page.getLayoutId()>

        <#assign pageName = page.getName(locale)>

        ${pageName}
        <#if currPageID==pageID >
            <p>True</p>
        <#else>
            <p>False</p>
        </#if>

    </#list>
</#if>
Romeo Sheshi
  • 901
  • 5
  • 7
  • Even though currPageName and pageName are the same, it's returning it as false. Any idea why it's not doing the string comparison properly? – Rohit Rajendran Jul 13 '16 at 20:35
  • is strange i test it, and it's working for me. i put the site map in the home page and i see this output `home True`. I'm using liferay 6.2 ce-ga4 – Romeo Sheshi Jul 13 '16 at 20:48
  • Weird I'm using liferay6.2 ee-sp14. The string comparison wasn't working for me when I was trying to do it by comparing url strings either. When I was comparing it, they were exactly the same. – Rohit Rajendran Jul 13 '16 at 20:54