From 42ef378bfff2e934821a7f10fd7ccb0fbc0361ce Mon Sep 17 00:00:00 2001 From: jensp Date: Sat, 23 Feb 2019 13:59:53 +0000 Subject: [PATCH] Freemarker macros for navigation data git-svn-id: https://svn.libreccm.org/ccm/trunk@5838 8810af33-2d31-482b-a856-94f89814c4df --- .../ccm-navigation/macros/navigation.ftl | 72 +++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl b/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl index cf895e4ca..e71745064 100644 --- a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl +++ b/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl @@ -5,7 +5,7 @@ "ui": "http://www.arsdigita.com/ui/1.0"} > -<%-- +<#-- Output all path tokens of the current category path. Provides the following parameters for nested content: @@ -14,7 +14,7 @@ 3: id of the category. ---%> +--> <#macro categoryPath> <#list model["/bebop:page/nav:categoryPath/nav:category"] as token> @@ -23,14 +23,14 @@ -<%-- +<#-- Provides the following data about the current navigation instance to the nested content: 1. ID of the navigation menu from which the data was retrieved 2. URL to the root of the navigation 3. title of the navigation ---%> +--> <#macro navigationRoot navId="categoryMenu"> <#assign url=model["/bebop:page/nav:categoryMenu[@id='${navId}']/nav:category/@url"]> @@ -40,43 +40,75 @@ +<#-- + Checks if the a categoryMenu is available in the model and shows the + nested content if one is available. The optional parameter + menuId can be used to select a specific categoryMenu is used. If no value + value the parameter is provided the default value "categoryMenu" is used. + + The categories are passed to the nested content. To iterate over the + categories the "categories" macro can be used. + +--> <#macro categoryMenu menuId="categoryMenu"> + <#if (model["/bebop:page/nav:categoryMenu[@id='${menuId}']"]?size > 0) > + <#nested model["/bebop:page/nav:categoryMenu[@id='${menuId}']/nav:category/nav:category"]> + + + <#-- <#assign categories=model["/bebop:page/nav:categoryMenu[@id='${menuId}']/nav:category/nav:category"]> <#list categories as category> <#nested category["./@id"], category["./@url"], category["./@title"], category> + --> +<#-- + Checks if an categoryHierachy is avialable in the model and shows the + nested content if one is avialable. The optional parameter hierarchyId + can be used to select a specific categoryHierarchy. If no value for the + parameter is provided the default value "categoryNav" is used. +--> <#macro categoryHierarchy hierarchyId="categoryNav"> + <#if (model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']"]?size > 0)> + <#nested model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']/nav:category"]> + + + <#-- <#assign categories=model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']/nav:category"]> <#list categories as category> <#nested category["./@id"], category["./@url"], category["./@title"], category> + --> + + + +<#-- + Iterates over the provided sequence of categories. For each category + the following parameters are passed to the nested content: + + 1. ID of the category + 2. URL of the category + 3. Title of the category + 4. The category itself. +--> +<#macro categories categories> + + <#list categories as category> + <#nested category["./@id"], category["./@url"], category["./@title"], category> + -<#macro ifHasSubCategories category> +<#macro subCategories ofCategory> - <#if (category?size > 0)> - - <#assign childs=category["./nav:category"]> - - <#if (childs?size > 0)> - <#nested> - + <#if (ofCategory["./nav:category"]?size > 0)> + <#nested ofCategory["./nav:category"]> - -<#macro subCategories ofCategory> - - <#list ofCategory["./nav:category"] as category> - <#nested category["./@id"], category["./@url"], category["./@title"], category["./nav:category"]> - - - \ No newline at end of file