The pagecounter macro does not work

Roksoliana Ben April 9, 2024

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?

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events