Navigation

A theme contains normally two types of navigation templates: a public and a intern one.

 

Use navigations in your layouts

Navigaion templates are templates which mainly contains a foreach on a navigation variable.

To trigger such a template, and therefore to display a navigation in your layout, you need this Smarty function:

 

{navigation [id=<pageId>] [level=<level>] template="templatePath" [folders="1"]}

 

  • id
    Define here a valid page id (or use level)
  • level
    Define here the level of the page tree(or use id)
  • template
    Define here the template path to your navigation template
  • folders
    Defines whether folders should be included or not. Default is false. Use "1" to activate it.

 

Level definition:

 

So for example for a main navigation you can use this code:

 

{navigation level="1" template="th_myTheme/navigation_main.tpl"}

 

Navigation templates

So, if you've inserted the {navigation} code in your layout then you need to create the specified template file.

In this file you have access to all global template variables and function and furthermore access to this special variable which is only present in navigation templates:

 

$navi is a array and contains all fields from kryn::getPage() and specially the item 'links' which contains all sub pages with the same scheme as $navi and so on.

 

Example navigation template
{foreach from=$navi.links item=link}
    <a class="{if $link|@active} active{/if}" title="{$link.title}"
       href="{$link|@realUrl}/">{$link.title}</a>
{/foreach}

Please notice the page modifiers like 'active' and 'realUrl'. It is very important that you use these modifiers in every navigation template.

 

Public navigations

Publicat navigations are templates like the normal templates, but a user can use this templates in the navigation element. You can define this templates in the extension editor.