Skip to content

Instantly share code, notes, and snippets.

@jdiepeveen
Created May 10, 2016 18:20
Show Gist options
  • Save jdiepeveen/9d136381ee79f4590a6f48e067e53187 to your computer and use it in GitHub Desktop.
Save jdiepeveen/9d136381ee79f4590a6f48e067e53187 to your computer and use it in GitHub Desktop.
Global include FreeMarker template for Magnolia CMS projects
[#-- Global assigns --]
[#assign editMode = cmsfn.editMode/]
[#assign authorInstance = cmsfn.authorInstance/]
[#assign previewMode = cmsfn.previewMode/]
[#-- Page's model & definition, based on the rendering hierarchy and not the node hierarchy --]
[#assign page = cmsfn.page(content)!]
[#assign pageModel = model.root!]
[#assign pageDef = pageModel.definition!]
[#assign pageType = pageDef.type!]
[#assign pageSubtype = pageDef.subtype!]
[#assign pageTitle = page.title!""]
[#assign pageAbstract = page.abstract!]
[#assign templateType = def.type!"content" /]
[#assign templateSubtype = def.subtype! /]
[#assign hasPageImage = false]
[#if page.image?has_content]
[#assign hasPageImage = true]
[#assign rendition = damfn.getRendition(page.image, "abstract")]
[#assign pageImageLink = rendition.link!]
[/#if]
[#assign site = sitefn.site()!]
[#assign theme = sitefn.theme(site)!]
[#assign siteRoot = cmsfn.siteRoot(content)!]
[#assign siteName = siteRoot.siteName!""]
[#-- Logo --]
[#assign hasLogo = false]
[#if siteRoot.logo?has_content]
[#assign hasLogo = true]
[#assign rendition = damfn.getRendition(siteRoot.logo, "logo")]
[#assign siteLogoLink = rendition.link!]
[/#if]
[#assign titleSeparator = siteRoot.separator!"|"]
[#assign homeLink = cmsfn.link(siteRoot)!"/" /]
[#-- Title --]
[#if page.windowTitle??]
[#assign metaTitle = page.windowTitle]
[#else]
[#assign contentPageTitle = model.title!page.title!page.@name /]
[#if siteRoot??]
[#if pageType == "home"]
[#assign metaTitle = siteName + " " + titleSeparator + " " + contentPageTitle /]
[#else]
[#assign metaTitle = contentPageTitle + " " + titleSeparator + " " + siteName /]
[/#if]
[#else]
[#assign metaTitle = contentPageTitle /]
[/#if]
[/#if]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment