NIHVIVO-2071 Include pageSetup.ftl in every page template. Use to generate a body class value, and apply to body element in page templates.

This commit is contained in:
rjy7 2011-02-08 21:07:16 +00:00
parent b3c13118d9
commit 17d41d281a
3 changed files with 25 additions and 1 deletions

View file

@ -55,6 +55,13 @@ public class TemplateProcessingHelper {
// can be used in directives. // can be used in directives.
env.setCustomAttribute("request", request); env.setCustomAttribute("request", request);
env.setCustomAttribute("context", context); env.setCustomAttribute("context", context);
// Define a setup template to be included by every page template
String templateType = (String) map.get("templateType");
if (templateType != null && templateType.equals(FreemarkerHttpServlet.PAGE_TEMPLATE_TYPE)) {
env.include(getTemplate("pageSetup.ftl"));
}
env.process(); env.process();
} catch (TemplateException e) { } catch (TemplateException e) {
log.error("Template Exception creating processing environment", e); log.error("Template Exception creating processing environment", e);

View file

@ -4,7 +4,7 @@
<#include "head.ftl"> <#include "head.ftl">
<body> <body class="${bodyClasses!}">
<div id="wrap" class="container"> <div id="wrap" class="container">
<div id="header"> <div id="header">

View file

@ -0,0 +1,17 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- pageSetup.ftl is automatically included for all page template requests.
It provides an avenue to assign variables related to display, which fall outside
the domain of the controllers. -->
<#assign bodyClasses>
<#-- The compress directives and formatting here resolve whitespace issues in output; please do not alter them. -->
<#compress>
<#assign bodyClassList = [currentPage!]>
<#if user.loggedIn>
<#assign bodyClassList = bodyClassList + ["loggedIn"]/>
</#if>
<#list bodyClassList as class>${class}<#if class_has_next> </#if></#list>
</#compress>
</#assign>