Is it possible to generate a list of spaces with their keys?

The Space macro and space directory are nice, but they don't provide any way to show the space key along with the space name.

It would be great if space key were available as a column in the space directory list.

Does anyone know of a workaround to generate such a list?

1 answer

1 accepted

3 votes
David Simpson Community Champion Jul 04, 2012

You could write a user macro to do that and output on a page.

Off the top of my head, something like:

$spaces = $spaceManager.getAllSpaces()

<ol>
#foreach ($space in $spaces)
  <li>$space.key $space.name</li>
#end
</ol>

Look at this page in the documentation (one of my favourites):
https://developer.atlassian.com/display/CONFDEV/Confluence+Objects+Accessible+From+Velocity

Hi David

This looks like exactly what I need. However ...

I'm not a programmer. I'm using Confluence 3.5.17. I tried pasting your code into a user macro. I called it listspacekeys, no body, output format wiki markup. When that didn't work, I tried output format html.

Unfortunately in both cases, all I got was a page of unhelpfulness, like this:

$spaces = [com.atlassian.confluence.spaces.Space@ecdba83, com.atlassian.confluence.spaces.Space@7897a853, com.atlassian.confluence.spaces.Space@fb1a477d, com.atlassian.confluence.spaces.Space@5a059e79, com.atlassian.confluence.spaces.Space@6d4138a0, com.atlassian.confluence.spaces.Space@42c67ec4, com.atlassian.confluence.spaces.Space@a45f4690, com.atlassian.confluence.spaces.Space@2ab1ef15, com.atlassian.confluence.spaces.Space@77f52313, com.atlassian.confluence.spaces.Space@368454f5, com.atlassian.confluence.spaces.Space@b57f41b7, com.atlassian.confluence.spaces.Space@d26d183e]

Am I missing something fundamental?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

640 views 21 11
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you