Freemarker macros for navigation data

git-svn-id: https://svn.libreccm.org/ccm/trunk@5838 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2019-02-23 13:59:53 +00:00
parent 2771e4e473
commit 42ef378bff
1 changed files with 52 additions and 20 deletions

View File

@ -5,7 +5,7 @@
"ui": "http://www.arsdigita.com/ui/1.0"} "ui": "http://www.arsdigita.com/ui/1.0"}
> >
<%-- <#--
Output all path tokens of the current category path. Provides the Output all path tokens of the current category path. Provides the
following parameters for nested content: following parameters for nested content:
@ -14,7 +14,7 @@
3: id 3: id
of the category. of the category.
--%> -->
<#macro categoryPath> <#macro categoryPath>
<#list model["/bebop:page/nav:categoryPath/nav:category"] as token> <#list model["/bebop:page/nav:categoryPath/nav:category"] as token>
@ -23,14 +23,14 @@
</#macro> </#macro>
<%-- <#--
Provides the following data about the current navigation instance to Provides the following data about the current navigation instance to
the nested content: the nested content:
1. ID of the navigation menu from which the data was retrieved 1. ID of the navigation menu from which the data was retrieved
2. URL to the root of the navigation 2. URL to the root of the navigation
3. title of the navigation 3. title of the navigation
--%> -->
<#macro navigationRoot navId="categoryMenu"> <#macro navigationRoot navId="categoryMenu">
<#assign url=model["/bebop:page/nav:categoryMenu[@id='${navId}']/nav:category/@url"]> <#assign url=model["/bebop:page/nav:categoryMenu[@id='${navId}']/nav:category/@url"]>
@ -40,43 +40,75 @@
</#macro> </#macro>
<#--
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"> <#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"]>
</#if>
<#--
<#assign categories=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> <#list categories as category>
<#nested category["./@id"], category["./@url"], category["./@title"], category> <#nested category["./@id"], category["./@url"], category["./@title"], category>
</#list> </#list>
-->
</#macro> </#macro>
<#--
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"> <#macro categoryHierarchy hierarchyId="categoryNav">
<#if (model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']"]?size > 0)>
<#nested model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']/nav:category"]>
</#if>
<#--
<#assign categories=model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']/nav:category"]> <#assign categories=model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']/nav:category"]>
<#list categories as category> <#list categories as category>
<#nested category["./@id"], category["./@url"], category["./@title"], category> <#nested category["./@id"], category["./@url"], category["./@title"], category>
</#list> </#list>
-->
</#macro>
<#--
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>
</#list>
</#macro> </#macro>
<#macro ifHasSubCategories category>
<#if (category?size > 0)>
<#assign childs=category["./nav:category"]>
<#if (childs?size > 0)>
<#nested>
</#if>
</#if>
</#macro>
<#macro subCategories ofCategory> <#macro subCategories ofCategory>
<#list ofCategory["./nav:category"] as category> <#if (ofCategory["./nav:category"]?size > 0)>
<#nested category["./@id"], category["./@url"], category["./@title"], category["./nav:category"]> <#nested ofCategory["./nav:category"]>
</#list> </#if>
</#macro> </#macro>