Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How Can I Get Space Count on Confluence?

Dogan Can March 31, 2014

Hi, I want to change Confluence Usage Stats plugin to display all projects in the confluence on the "Global Activity" section so I tried to overwrite the plugin. Now I can change the number of spaces by setting "max" parameter, but I need to the total project(or space) count to "max" parameter. How can get the total space count and use it? It can be like this:

#set ($spaceCount = "display=count|spaces=@all")
$helper.renderConfluenceMacro("{popular:display=icon,count|max=$spaceCount|type=spaces|$commonParams}")

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Dogan Can April 1, 2014
#set ($spaceCount = 0)
#foreach ($space in $spaceManager.getAllSpaces()) 
	#set ($spaceCount = $spaceCount + 1) 
#end<br />

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 1, 2014

It gets easier than that.

$spaceManager.getAllSpaces().size()

azher khan July 23, 2018

where we can run this code confluence 

0 votes
Hsu Yao Chang September 7, 2015

dear sir, 

Where can I add the command ? Thank you.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2015

The above code is for a user macro. Go to Confluence Admin -> User Macros to create one. After you create the user macro it will show up in your macro browsers. Below are some links for how to create user macros. https://confluence.atlassian.com/doc/user-macro-template-syntax-223906130.html https://developer.atlassian.com/confdev/development-resources/confluence-architecture/confluence-internals/velocity-template-overview/confluence-objects-accessible-from-velocity

TAGS
AUG Leaders

Atlassian Community Events