From bd2de4c0ca21f3b5e81de51e4b0f05b1faf326f5 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 13 Mar 2019 16:48:59 +0000 Subject: [PATCH] Freemarker macros for image attachments git-svn-id: https://svn.libreccm.org/ccm/trunk@5865 8810af33-2d31-482b-a856-94f89814c4df --- .../ccm-cms-assets-imagestep/macros.ftl | 31 +++++++++++++++++++ .../ccm-navigation/macros/objectlist.ftl | 4 +-- .../web/themes/freemarker/macros.ftl | 9 ++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep/macros.ftl diff --git a/ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep/macros.ftl b/ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep/macros.ftl new file mode 100644 index 000000000..f0dbe2bc7 --- /dev/null +++ b/ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep/macros.ftl @@ -0,0 +1,31 @@ +<#ftl ns_prefixes={ +"bebop":"http://www.arsdigita.com/bebop/1.0", +"cms":"http://www.arsdigita.com/cms/1.0", +"nav":"http://ccm.redhat.com/navigation", +"ui": "http://www.arsdigita.com/ui/1.0"} +> + +<#-- + Extracts the image attachments of an item if any and passes them to the + nested content. +#--> +<#macro imageAttachments item> + <#if (item["./imageAttachments"]?size > 0)> + <#nested item["./imageAttachments"]> + + + +<#-- + Passes the data of a single image attachments to the nested content. The + following data is passed to the nested content: + + * id of the image + * file name of the image + * caption of the images + * sort key of the image + * width of the image + * height of the image +--> +<#macro imageAttachment image> + <#nested image["./image/id"], image["./image/name"], image["./caption"] image["./sortKey"], image["./image/width"], image["./image/height"]> + \ No newline at end of file diff --git a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/objectlist.ftl b/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/objectlist.ftl index 7cd975eb0..8d38d76c0 100644 --- a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/objectlist.ftl +++ b/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/objectlist.ftl @@ -9,8 +9,8 @@ <#if (model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList"]?size > 0)> <#-- <#assign items=model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList/nav:item"]> --> -
Found simple object list ${listId}
-

+        <#--  
Found simple object list ${listId}
+
  -->
         <#nested model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList/nav:item"]>
     <#elseif (model["/bebop:page/nav:complexObjectList[@id='${listId}']/nav:objectList"]?size > 0)>
         
Found complex object list ${listId}
diff --git a/ccm-themedirector/web/themes/freemarker/macros.ftl b/ccm-themedirector/web/themes/freemarker/macros.ftl index 531e752ae..0a6650ff1 100644 --- a/ccm-themedirector/web/themes/freemarker/macros.ftl +++ b/ccm-themedirector/web/themes/freemarker/macros.ftl @@ -10,3 +10,12 @@ ${model["//nav:categoryMenu/nav:category/@title"]} +<#function getBooleanAttrValue fromNode attrName> + <#assign path='@' + attrName> + <#if (fromNode[path]?size > 0)> + <#assign value=fromNode[path][0]> + <#return value?lower_case?switch('true', true, 'false', false, 'yes', true, 'no', false, false)> + <#else> + <#return false> + + \ No newline at end of file