diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerComponentGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerComponentGenerator.java index 678728242..4a350e25c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerComponentGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerComponentGenerator.java @@ -34,7 +34,7 @@ public class FreemarkerComponentGenerator extends FreemarkerHttpServlet { // root is the map used to create the page shell - header, footer, menus, etc. Map root = getSharedVariables(vreq, new HashMap()); - root.putAll(getRootValues(vreq)); + root.putAll(getPageTemplateValues(vreq)); request.setAttribute("ftl_identity", get("identity", root, config)); request.setAttribute("ftl_menu", get("menu", root, config)); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java index 17fdcca6a..7b0d0ea34 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java @@ -266,16 +266,22 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { // root is the map used to create the page shell - header, footer, menus, etc. Map root = new HashMap(sharedVariables); - - // body is the map used to create the page body - Map body = new HashMap(sharedVariables); - root.putAll(getRootValues(vreq)); + root.putAll(getPageTemplateValues(vreq)); + // Tell the template and any directives it uses that we're processing a page template. + root.put("templateType", "page"); // Add the values that we got, and merge to the template. String bodyTemplate = values.getTemplateName(); String bodyString; if (bodyTemplate != null) { + // body is the map used to create the page body + // Adding sharedVariables before bodyMap values is important. If the body + // processing has changed a shared value such as title, we want to get that + // value. + Map body = new HashMap(sharedVariables); body.putAll(bodyMap); + // Tell the template and any directives it uses that we're processing a body template. + body.put("templateType", "body"); bodyString = mergeMapToTemplate(bodyTemplate, body, config); } else { // The subcontroller has not defined a body template. All markup for the page @@ -447,10 +453,10 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { // Add variables that should be available only to the page's root map, not to the body. // RY This is protected instead of private so FreeMarkerComponentGenerator can access. // Once we don't need that (i.e., jsps have been eliminated) we can make it private. - protected Map getRootValues(VitroRequest vreq) { + protected Map getPageTemplateValues(VitroRequest vreq) { - Map root = new HashMap(); - root.put("tabMenu", getTabMenu(vreq)); + Map map = new HashMap(); + map.put("tabMenu", getTabMenu(vreq)); Portal portal = vreq.getPortal(); @@ -458,26 +464,26 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { PortalWebUtil.populateSearchOptions(portal, appBean, vreq.getWebappDaoFactory().getPortalDao()); PortalWebUtil.populateNavigationChoices(portal, vreq, appBean, vreq.getWebappDaoFactory().getPortalDao()); - root.putAll(getLoginValues(vreq)); + map.putAll(getLoginValues(vreq)); UrlBuilder urlBuilder = new UrlBuilder(portal); - root.put("version", getRevisionInfo(urlBuilder)); + map.put("version", getRevisionInfo(urlBuilder)); - root.put("copyright", getCopyrightInfo(portal)); - root.put("siteTagline", portal.getShortHand()); - root.put("breadcrumbs", BreadCrumbsUtil.getBreadCrumbsDiv(vreq)); + map.put("copyright", getCopyrightInfo(portal)); + map.put("siteTagline", portal.getShortHand()); + map.put("breadcrumbs", BreadCrumbsUtil.getBreadCrumbsDiv(vreq)); String themeDir = getThemeDir(portal); // This value is used only in stylesheets.ftl and already contains the context path. - root.put("stylesheetPath", UrlBuilder.getUrl(themeDir + "/css")); + map.put("stylesheetPath", UrlBuilder.getUrl(themeDir + "/css")); String bannerImage = portal.getBannerImage(); if ( ! StringUtils.isEmpty(bannerImage)) { - root.put("bannerImage", UrlBuilder.getUrl(themeDir + "site_icons/" + bannerImage)); + map.put("bannerImage", UrlBuilder.getUrl(themeDir + "site_icons/" + bannerImage)); } - return root; + return map; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/login/LoginTemplateHelper.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/login/LoginTemplateHelper.java index 7af6d4c3e..83c2f5c43 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/login/LoginTemplateHelper.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/login/LoginTemplateHelper.java @@ -159,7 +159,7 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase { Map sharedVariables = getSharedVariables(vreq, new HashMap()); Map root = new HashMap(sharedVariables); Map body = new HashMap(sharedVariables); - root.putAll(getRootValues(vreq)); + root.putAll(getPageTemplateValues(vreq)); // Add the values that we got, and merge to the template. body.putAll(values.getMap());