سؤال

I've managed to create a custom page template for Magnolia CMS pretty easily following this tutorial:

http://documentation.magnolia-cms.com/templates/introduction.html

However, I'm at the point where I'd like to insert the navigation into my template but I can't find a simple way to do so. It looks like other's have had this problem with no clear way to fix it. Does anyone know how to easily include the navigation? Thanks

هل كانت مفيدة؟

المحلول

If you're using Magnolia CE (Community Edition) 4.5.x, you need to know that basically every page template extends the one defined in /modules/standard-templating-kit/config/site/templates/prototype. There you have a node, /navigation. You can copy that node to your new custom template, and after that you can start playing with it's properties.

But before that, don't forget to include the navigation menu(s) somewhere in your main template file (.ftl) and make your template to use stk model class info.magnolia.module.templatingkit.templates.pages.STKPageModel (add an attribute to your template named modelClass, look at stkArticle (or stkSection), it's a good place to start)

Horizontal navigation:

[#if def.navigation.top]
    [#include def.navigation.horizontal.template]
[/#if]

Vertical nav:

[#if def.navigation.top]
    [#include def.navigation.vertical.template]
[/#if]

If you want to include your menu in another template included with a [@cms.area ...] tag, you can use this code:

[#if model.root.def.navigation.top]
    [#include model.root.def.navigation.vertical.template]
[/#if]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top