Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Macro to display a list of space names with space keys for a site.

Carolyn Phillips July 29, 2019

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

1 answer

1 accepted

0 votes
Answer accepted
Carolyn Phillips July 29, 2019

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>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events