Hello,
I need to count the number of pages per space. I still use a Confluence Server instance.
I added the code to configure the pagecounter macro, but it does not work.
Here is the code:
Macro title: Page counter
Macro has a body: 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>
Do you have any clue or could you give me a hint about how to fix it?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.