Mustapha Aoussar
Mustapha Aoussar

Reputation: 5923

How to get list of pages in WCM (Liferay)?

I tried to create a Web Content with a Template that contains the navigation (list of pages):

<nav id="navigation">
    <ul>
        <#list nav_items as nav_item>
            <#assign nav_item_css_class = "" />

            <#if nav_item.isSelected()>
                <#assign nav_item_css_class = "selected" />
            </#if>

            <li class="${nav_item_css_class}">
                <a href="${nav_item.getURL()}">${nav_item.getName()}</a>

                <#if nav_item.hasChildren()>
                    <ul class="child-menu">
                        <#list nav_item.getChildren() as nav_child>
                            <#assign nav_child_css_class = "" />
                            <#if nav_item.isSelected()>
                                <#assign nav_child_css_class = "selected" />
                            </#if>
                            <li class="${nav_child_css_class}">
                                <a href="${nav_child.getURL()}">${nav_child.getName()}</a>
                            </li>
                        </#list>
                    </ul>
                </#if>
            </li>
        </#list>
    </ul>
</nav>

But I get this error:

Expression nav_items is undefined

In my theme navigation.ftl it works but in the WCM ftl (FreeMarker) doesn't work. Then, how can I get the list of pages in WCM?

Upvotes: 2

Views: 1592

Answers (1)

Tomas Pinos
Tomas Pinos

Reputation: 2862

The list of pages is available only in ADTs (Application Display Templates), not in WCM templates.

If you really need the list and can use ADTs, use navItems variable instead. The variable nav_items only works in themes (for backward compatibility, I guess).

Documentation - hard to find. Use the force, read the source - on GitHub.

You may want to use a handy Freemarker script to display all available variables - see Dumping ADT+WCM Template Variables on James Falkner's blog.

Upvotes: 3

Related Questions