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)

Captura de pantalla 2019-05-03 a las 18.49.31.png

 

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

 

Advertisements
Posted by:.

One thought on “New Macro to show a list of spaces and pages and last modified date in Confluence

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s