Freemarker macros for image attachments

git-svn-id: https://svn.libreccm.org/ccm/trunk@5865 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2019-03-13 16:48:59 +00:00
parent 65f587b0ae
commit bd2de4c0ca
3 changed files with 42 additions and 2 deletions

View File

@ -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"]>
</#if>
</#macro>
<#--
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"]>
</#macro>

View File

@ -9,8 +9,8 @@
<#if (model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList"]?size > 0)> <#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"]> --> <#-- <#assign items=model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList/nav:item"]> -->
<pre>Found simple object list ${listId}</pre> <#-- <pre>Found simple object list ${listId}</pre>
<pre></pre> <pre></pre> -->
<#nested model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList/nav:item"]> <#nested model["/bebop:page/nav:simpleObjectList[@id='${listId}']/nav:objectList/nav:item"]>
<#elseif (model["/bebop:page/nav:complexObjectList[@id='${listId}']/nav:objectList"]?size > 0)> <#elseif (model["/bebop:page/nav:complexObjectList[@id='${listId}']/nav:objectList"]?size > 0)>
<pre>Found complex object list ${listId}</pre> <pre>Found complex object list ${listId}</pre>

View File

@ -10,3 +10,12 @@
${model["//nav:categoryMenu/nav:category/@title"]} ${model["//nav:categoryMenu/nav:category/@title"]}
</#macro> </#macro>
<#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>
</#if>
</#function>