How to add navigation to custom Magnolia CMS template?
I was able to create my own page template for Magnolia CMS quite easily following this tutorial:
http://documentation.magnolia-cms.com/templates/introduction.html
However, I am at the point where I would like to insert the navigation into my template, but I cannot find an easy way to do this. It looks like others have had this problem without a clear way to fix it. Does anyone know how easy it is to enable navigation? Thanks to
source to share
If you are using Magnolia CE (Community Edition) 4.5.x, you need to be aware that basically each page template extends the value defined in /modules/standard-templating-kit/config/site/templates/prototype
. There you have node, /navigation
. You can copy this node into your new custom template, after which you can start playing with its properties.
But before that, remember to include the nav menu somewhere in your main template file ( .ftl
) and make your template use the stk model class info.magnolia.module.templatingkit.templates.pages.STKPageModel
(add an attribute to your template named modelClass, look at stkArticle (or stkSection), that's a good place to start)
Horizontal navigation:
[#if def.navigation.top]
[#include def.navigation.horizontal.template]
[/#if]
Vertical navigator:
[#if def.navigation.top]
[#include def.navigation.vertical.template]
[/#if]
If you want to include your menu in another template included in the tag [@cms.area ...]
you can use this code:
[#if model.root.def.navigation.top]
[#include model.root.def.navigation.vertical.template]
[/#if]
source to share