CMS / 03. Navigation
Updated: 30. January 2020
Author: Peter Širka

03. Navigation

Professional Support Chat with contributors

Each navigation needs to be defined in some template. The entire functionality of navigation is stored in the model /models/navigations.js.

What should i know?

  • navigation can contain links with advanced settings
  • navigation needs to be rendered manually
  • all navigations are loaded into the memory when the app is started

Create navigation

Each navigation needs to be defined in templates (Pages section) and templates can contain unlimited counf of navigations, for example: mainmenu, footer, etc..


@{navigation mainmenu:Main menu}
@{navigation footer:Footer menu}

<!DOCTYPE html>
  • navigation must be defined via @{navigation ID:NAME} command in the page template
  • navigation must be rendered manually by developer
  • navigation is automatically created when the template is submitted
  • CMS merges all navigations together according to the ID

Links need to be added into the navigation manually. Just open Pages section and choose your navigation in the right panel. CMS shows all registered navigations:


Good to know:

Some links can be linked automatically if the user choose a page according to the sitemap. User can specify in the Page settings what fields can be synchronized in navigations:

Navigation in Page settings


Navigations are stored in a global static object: and each navigation needs to be rendered manually.

Navigation item:

// var nav = MAIN.navigations.navigation_id;
// For example:
var nav = MAIN.navigations.mainmenu;

// Contains relative URL addresses. It's a quick access to rendering sub-links according to the URL
// returns {Array Object}

// Contains all registered links
// returns {Array Object}

// The last date of update
// returns {Datetime}

// Serializes this navigation to JSON
// returns {String}

Link object:

var item = nav.url['/products/'];
// or
var item = nav.children[0];

// Contains a parent of this item and returns same object structure
// returns {Object}

// Contains a number of level
// returns {Number}

// Contains all children with same structure as this object
// returns {Array Object}

// A link URL address
// returns {String};
// A link name
// returns {String}

// A title for tooltip
// returns {String};
// A value for link "_target", can contain "_self" or "_blank"
// returns {String}

// An icon (font-awesome without "fa-")
// returns {String}

// Page ID according to the sitemap
// returns {UID};
// Unique identificator of link
// returns {String}

// This property can contain these values "default", "info", "warn", "highlight" or "special"
// This feature needs to be coded manually
// returns {String}

item.contains(url, [absolute]);
// Determines whether this item contains "url". It's a great solution for highlighting item in navigation
// @url {String} Relative URL address
// @absolute {Boolean} Only compares this item and its all childs (default: false)
// returns {Boolean}

Rendering in views

I recommend to render a navigation in a layout, but navigation can be rendered everywhere. Just follow your needs.

Quick rendering:

@{foreach m in MAIN.navigations.mainmenu.children)
    <a href="@{m.url}">@{}</a>    

Wich icon, tooltip and target:

@{foreach m in MAIN.navigations.mainmenu.children}
    <a href="@{m.url}"@{if === '_blank'} target="_blank"@{fi}@{if m.title} titlte="@{m.title}"@{fi}>@{if m.icon}<i class="fa fa-@{m.icon}"></i>@{fi}@{}</a>    

With the first-level of children:

@{foreach a in MAIN.navigations.mainmenu.children}

    <a href="@{a.url}">@{}</a>
    @{if a.children.length}
        @{foreach b in a.children}
            <a href="@{b.url}">@{}</a>

Render children according to the URL:

@{if MAIN.navigations.mainmenu.url[url] && MAIN.navigations.mainmenu.url[url].parent}

    @{foreach a in MAIN.navigations.mainmenu.url[url].parent.children}

        <a href="@{a.url}">@{}</a>

        <!-- Rendering the first-level of children -->
        @{if a.children.length}
            @{foreach b in a.children}
                <a href="@{b.url}">@{}</a>