The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events