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:
parent
b3c13118d9
commit
17d41d281a
3 changed files with 25 additions and 1 deletions
|
@ -55,6 +55,13 @@ public class TemplateProcessingHelper {
|
|||
// can be used in directives.
|
||||
env.setCustomAttribute("request", request);
|
||||
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();
|
||||
} catch (TemplateException e) {
|
||||
log.error("Template Exception creating processing environment", e);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<#include "head.ftl">
|
||||
|
||||
<body>
|
||||
<body class="${bodyClasses!}">
|
||||
<div id="wrap" class="container">
|
||||
<div id="header">
|
||||
|
||||
|
|
17
webapp/web/templates/freemarker/page/partials/pageSetup.ftl
Normal file
17
webapp/web/templates/freemarker/page/partials/pageSetup.ftl
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue