Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleClick here to see the navigation macro


Code Block
languagexml
title/templates/macros/navigation.ftl
[#-- Basic navigation macro which generates simple navigation. You can adjust it to fulfil your needs. --]
[#macro navigation navParentItem depth=1 expandAll=false navClass="nav"]

    [#if navParentItem?has_content && depth > 0]
    <ul class="${navClass}">

        [#assign navItems = navfn.navItems(navParentItem)]
        [#list navItems as navItem]
            [#-- This is example how to resolve navigation from the content apps. Uncomment and adjust to your needs.
            [#if navfn.hasTemplate(navItem, "mtk:pages/contactsOverview") || navfn.hasTemplateSubtype(navItem, "contactsOverview")]
                <li>
                    [#if navfn.isHiddenInNav(navItem)]
                        <a href="#">${navItem.navigationTitle!navItem.title!navItem.@name}</a>
                    [#else]
                        <a href="${cmsfn.link(navItem)!"#"}">${navItem.navigationTitle!navItem.title!navItem.@name}</a>
                    [/#if]
                    <ul>
                        [#assign navContentItems = navfn.navItemsFromApp("contacts", "/", "mgnl:contact")]
                        [#list navContentItems as navContentItem]
                            <li><a href="${navfn.linkWithSelector(navItem, navContentItem)!"#"}">${navContentItem.lastName!navContentItem.@name}</a></li>
                        [/#list]
                    </ul>
                </li>
            [#else]
            --]
                [#assign activeNavItem = navfn.isActive(content, navItem)] [#-- Active navigation item is the one which is same as current page--]
                [#assign openNavItem = navfn.isOpen(content, navItem)] [#-- Open navigation item is the one which is ancestor of current page--]
                [#if activeNavItem]
                    <li class="active">
                [#elseif openNavItem]
                    <li class="open">
                [#else]
                    <li>
                [/#if]
                        <a href="${navfn.link(navItem)!"#"}">${navItem.navigationTitle!navItem.title!navItem.@name}</a>
                        [#if expandAll || activeNavItem || openNavItem]
                            [@navigation navItem depth-1 /]
                        [/#if]
                    </li>
            [#-- End 'if' for navigation from the content apps]
            [/#if]
            --]
        [/#list]
    </ul>
    [/#if]
[/#macro]

Standard Templating Kit

Standard Templating Kit (STK) is the predecessor to MTE. It provides best practices and templates for many common use cases. However, as front-end Web technologies have evolved and front end frameworks such as Twitter Bootstrap have emerged, developers found the STK too opinionated and monolithic. They were looking for something leaner, more adaptable and less time-consuming to learn. The MTE was created to meet this demand.  

Info

You can run still STK projects on Magnolia 5.5. Include STK in your project

For more information about STK, please see the Magnolia 5.4 documentation.



 

Credits: