Hi,
Wondering how to write a macro that will display a list of space names with their keys for a site.
I have seen the option for displaying a table of users and spaces but have been unsuccessful at adapting it.
Any help would be appreciated.
Thanks,
Carolyn
Looks like I have a solution with some help from a colleague and another script I found on here.
## Macro title: Space Details
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Modified by: Mike Marriott and Carolyn Phillips
## Date created: 21/03/2012
## Date modified: 30/07/2019
## Installed by: Carolyn Phillips
## Macro to display a list of spaces with their keys
## @noparams
#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($spaces = $spaceManager.getAllSpaces())
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Spaces</th><th class="confluenceTh">Space Key</th>
</tr>
#foreach($spacer in $spaces)
<tr>
<td class="confluenceTd">$spacer.name</td>
<td class="confluenceTd"><a href="$req.contextPath/display/$spacer.key">$spacer.key</a></td>
</tr>
#end
</table>
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.