Hi Sarah,
you can define the following macro :
## Macro title: My Macro
## Macro has a body: Y or N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Fabio Racobaldo
## Date created: 28/03/2018
## Installed by: Fabio Racobaldo
## @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($users = $userAccessor.getUsers())
#set($spaces = $spaceManager.getAllSpaces())
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Space Administrator</th><th class="confluenceTh">Space</th>
</tr>
#foreach($user in $users)
#if ($permissionHelper.canAdminister($user, $space))
<tr>
<td class="confluenceTd">#usernameLink($user.name)</td><td class="confluenceTd"><a href="$req.contextPath/display/$spacer.key">$space.name</a></td>
</tr>
#end
#end
</table>
Hope this helps.
Ciao,
Fabio
Hey Fabio,
Thanks for much for coming back to me, very much appreciated!
I'm not the most advanced user of Confluence - I've created this user macro with your details above, but it seems to pull through a list of every space and every space admin.
I've got a very basic Space Admin Tag macro that it might be worth just editing (as per below)- I've attached what this looks like front end, and essentially does everything I need it to - just need to have it display the space admin of the space the user is in, not a predefined space key. Does that make sense?
-------
## @param SpaceKey:title=The Space Key|type=string|required=true|desc=Use the space key to determine who the Space Admins are
#set($thisSpace = "")
#if($paramSpaceKey)
#set($thisSpace = $spaceManager.getSpace($paramSpaceKey) )
#else
##set($thisSpace = $space )
#end
#if ($thisSpace)
<!-- $paramSpaceKey -->
#set($spaceadmins = $spaceManager.getSpaceAdmins($thisSpace))
#set ($counter = 0)
#if ($spaceadmins.size() > 0)
<span>Space Admin:</span>
#foreach($spaceadmin in $spaceadmins)
#if ($counter < 2)
#if ($counter > 0)<span>,</span>#end
<span class="spaceadmin-user"><a href="mailto:$spaceadmin.getEmail()">$spaceadmin.getFullName()</a></span>
#set ($counter = $counter + 1)
#end
#end
#end
#end
---------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarah,
the provided code should retrieve information just about the space related to the page in with the macro is used. I just tested it to my environment and it works.
Are you sure that you are using the correct one?
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.