Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Changed title as proposed by Antti

...

If you are an existing customer with STK based templates, you can still use the Standard Templating Kit. Note however that, although the STK is still maintained, it will not be actively developed further.

Magnolia recommends you start all new projects with MTE.

Table of Contents

MTE and MTK

Include Page
_What is the MTE
_What is the MTE

...

MTK template definitions

The MTK module includes Using the Magnolia Templating KitPagesUsing the Magnolia Templating Kit and Using the Magnolia Templating KitAreas and Components templates and associated dialogs.

Page template

The basic page template is a good starting point for custom page templates.

...

Areas

The areas are defined in the page template (see the areas node below). Areas typically define what components editors can place inside the area (see the availableComponents node in footer and main areas below).

Code Block
title/templates/pages/basic.yaml
templateScript: /mtk/templates/pages/basic.ftl
dialog: mtk:pages/basic
renderType: freemarker
class: info.magnolia.module.site.templates.PageTemplateDefinition
cssFiles:
  normalize:
    link: /.resources/mtk/css/normalize-3.0.3.css
  main:
    link: /.resources/mtk/css/html5boilerplate-main-5.3.0.css
  video:
    link: /.resources/mtk/css/video.css
jsFiles:
  modernizr:
    link: /.resources/mtk/js/modernizr-2.8.3.min.js
areas:
  htmlHeader:
    type: noComponent
    createAreaNode: false
    templateScript: /mtk/templates/areas/htmlHeader.ftl
  navigation:
    type: noComponent
    createAreaNode: false
    templateScript: /mtk/templates/areas/navigation.ftl
  footer:
    inheritance:
      components: all
      enabled: true
    availableComponents: &footerAvailableComponents
      link:
        id: mtk:components/link
      textImage:
        id: mtk:components/textImage
      image:
        id: mtk:components/image
  main:
    availableComponents: # using all components from footer plus others
      <<: *footerAvailableComponents
      html:
        id: mtk:components/html
      linkList:
        id: mtk:components/linkList
      teaser:
        id: mtk:components/teaser
      video:
        id: mtk:components/video
      pageIntro:
        id: mtk:components/pageIntro

Components

The MTK provides basic components for use in your templates:

Text and image

ID: mtk:components/textImage

Displays text and an image.

ID: mtk:components/link

Creates a link to an internal or external page or a downloadable asset.

ID: mtk:components/linkList

Organizes link components into a bulleted, inline or ordered list.

Image

ID: mtk:components/image

Displays an image.

Teaser

ID: mtk:components/teaser

Promotes another Magnolia page, third-party website or a downloadable asset, inviting the visitor to click for more.

HTML

ID: mtk:components/html

Allows editors to enter HTML markup and renders it on the page.

Video

ID: mtk:components/video

Adds the possibility to add a video. Videos can be taken from the assets app - or you may just add "embed code" as provided by youtube and other public video repositories.

Page intro

ID: mtk:components/pageIntro

A component to render the page properties title and abstract.

Navigation

The MTK provides basic navigation to use in your templates. Add subpages to see the navigation.  

...

The navigation is provided by two scripts that use navfn templating functions which are included in the MTE module.

The navigation area is rendered by the navigation.ftl script. This script sets the root page, navigation depth and behavior, and includes the navigation.ftl macro. 

...

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 &amp;&amp; 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.  

...