Hey folks,
we used a macro showing the description and the name of all spaces with a certain category which has to be inserted in the macro as parameter.
We have added all needed actions to the cataina_opts parameter and checked the logfile for missing allowlist entries and added them as well to the according environment parameter but the macro isn´t showing any results. Has anyone a hint, whats wrong with it?
## Macro title: List spaces from category
## Macro has a body: N
##
## Adapted from several answers at https://community.atlassian.com/t5/Confluence-questions/Show-a-Space-List-within-a-page-using-Category-label/qaq-p/149585
## Date created: 19/02/2021
## @param CategoryLabel:title=Space Category|type=string|required=true|desc=The category you want to list spaces from.
## @param CategoryHeading:title=Heading|type=string|required=false|desc=Heading of first column in result table.
## try to get space category
#set ($spaceLabel = "projects")
## check if space category exists
#if ($!spaceLabel)
## try to get spaces by category
#set ($spaces = $action.labelManager.getSpacesWithLabel($spaceLabel))
## sort spaces alphabetically with bubble sort - takes n^2 passes
#set ($outerCnt = -1)
#foreach ($outerSpace in $spaces)
#set ($outerCnt = $outerCnt + 1)
#if ($outerCnt < $spaces.size()) ##Preventing bad array access
#set ($innerCnt = -1)
#foreach ($innerSpace in $spaces)
#set ($innerCnt = $innerCnt + 1)
#if ($innerCnt < $spaces.size()) ##Preventing bad array access
## Compare this and previous. If this is smaller, swap
#if ($innerSpace.name.compareToIgnoreCase($spaces.get($outerCnt).name) > 0 )
#set ($tmp = $spaces.get($outerCnt))
#set ($outerSpace = $spaces.set($outerCnt, $innerSpace))
#set ($outerSpace = $spaces.set($innerCnt, $tmp))
#end
#end
#end
#end
#end
<table>
<tr>
#if (${paramCategoryHeading})
<th>${paramCategoryHeading}</th>
#else
<th>Bereich</th>
#end
<th>Beschreibung</th>
</tr>
#foreach ($space in $spaces)
## check if current user can view space
#if ($permissionHelper.canView($action.remoteUser, $space))
#set ($spaceDescription = $space.getDescription())
<tr>
<td><a href="$!space.urlPath">$!space.name</a></td>
<td>$spaceDescription.getBodyAsString()</td>
</tr>
#end
#end
</table>
#else
<div class="aui-message warning">
<p class="title">
<span class="aui-icon icon-warning">Warning</span>
<strong>Space category not found</strong>
</p>
<p>Couldn't find space category <strong>$paramLabel</strong>!</p>
</div>
#end
many thanks for any help!
regards
Hendrik
Hi.
Labelmanager has been removed from supported Atlassian functionality. We updated to Confluence 9.2 and our custom macro to list spaces according to their category also borked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Shawn,
it´s a user macro we defined in the system configuration using the code mentioned above. It worked for years, but stopped working something like a year ago. Do you have any hint, why it is not showing any results? It just says "Couldn´t find space category $paramLabel" - the "$paramLabel" is not resolved to the category we´ve added..
Thanks and regards
Hendrik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would assume if it stopped working one of it's dependencies changed, maybe during an update.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.