This User Macro is very useful:
- You can count pages in spaces
- You can obtain the last modified date (and the modifier author if you want)
- You can show a list of spaces with links to quick access
- You can “clean” or “archive” old spaces
Installation instructions: (see picture)
The Template of code (the source):
<pre>
## Macro title: Page counter
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Cedric DEVAUX
## Date created: 21/07/2014
## Modified by: Raul Pelaez MRADDON
## Date modified: 03/05/2019
## Macro to count pages in the space.
## @noparams
## Settings
#set($containerManagerClass=$action.class.forName(‘com.atlassian.spring.container.ContainerManager’))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod(‘getInstance’,null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
## the spaceManager gives you access to the spaces
#set($spaceManager =$containerContext.getComponent(‘spaceManager’))
<h2>List of Spaces</h2>
<table class=”confluenceTable”>
<tr>
<th class=”confluenceTh”>Space Name</th>
<th class=”confluenceTh”>Page Count</th>
<th class=”confluenceTh”>Last Modified</th>
</tr>
#foreach($sp in $spaceManager.getAllSpaces())
#if($sp.isGlobal())
<tr>
<td>
<a href=”/display/$sp.getKey()”>$sp.getName()</a>
</td>
<td>
$spaceManager.findPageTotal($sp)
</td>
<td>
$sp.getLastModificationDate()
<!–$sp.getLastModifierName()–>
</td>
</tr>
#end
#end
</table>
</pre>
Macro based on this post
By MrAddon
The best Welcome Message of Confluence!
LikeLike
Hello Mr Addon,
Surprised and happy to see my confluence macro on your website 🙂
Enjoy 😉
Cedric Devaux
LikeLiked by 1 person
Thanks to you Cedric for share your macro!!
LikeLike
Hello ,
I tried with the above macro, But I am getting the following errors.
Error rendering macro ‘pagecounter’
Error occurred rendering template content
Could you please help with this error.
Thanks in advance
LikeLike
Hello Rama,
Just copy the code between PRE tags and paste in your Confluence Macro config section.
Remember to replace the (“) characters by (“) correct ones… is a typical problem of WordPress pages (they process the content of the page and replace some parts)
Regards
LikeLike