Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Total number of pages in a space - how?

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Hello,

I want to find out how many pages are in a space. More than that I want to know if it's possible to see how many sub-pages there are under a given head page.

I can't see anything about there here or in the Admin's user guide.

Cheers.

3 answers

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 7, 2013

For automation you can use getPageList from Confluence Command Line Interface with the appropriate parameters:

--action getPageList --space xxx --file /dev/null
36 pages in list written to file: /dev/null

--action getPageList --space xxx --title home --file /dev/null --descendents
22 pages in list written to file: /dev/null

0 votes
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Oh, this is a "user macro". You need to create a new macro and then add it to a page. Here's info on creating macros:

https://confluence.atlassian.com/display/DOC/Writing+User+Macros

Most of the info on that page you can skip, except: navigate to the user macro creation page, give the macro a name, and paste the body into the body field. Then go to a page in your space, open in edit mode, and add the macro by selecting Insert > Other Macros.

hth,

matt

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Matt,

thanks, I appreciate your time and effort on this. I'll have a look and give it a go asap. :) Cheers.

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Great, just tried it and I don't have the correct level of permission to do this! :) I've sent it to our big admins to see if they can. Cheers.

0 votes
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

You can do this with a macro, like this:

## Macro title: Count Children
## Macro has a body: N
## Body processing: n/a
## Output: HTML
##
## Developed by: Matthew J. Horn
## Date created: 08/07/2013
## @noparams

#set ($pageListArray = [])
#set ($spaceHome = $space.getHomePage())

#macro ( process $rp )
  #set ($pagelist = $rp.getSortedChildren() )  ## returns List<Page>
  #foreach( $child in $pagelist )
    #set($p = $pageListArray.add( $child ) )
    #if( $child.hasChildren() )
      #process ( $child )
    #end
  #end
#end
#process ( $spaceHome )

<table class="confluenceTable">
 <tbody>
 <tr>
  <th class="confluenceTh">Title</th>
  <th class="confluenceTh">Num Children</th>
 </tr>

 #foreach( $child in $pageListArray)   ## child is of type Page
   <tr>
     <td class="confluenceTd">$child.getTitle()</td>
     <td class="confluenceTd">$child.getChildren().size()</td>
   </tr>
 #end 
</tbody>
</table>

Total pages: $pageListArray.size()

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Matthew,

Thanks for doing all that.

I've just tried adding this into the HTML view and saving the page. Whilst the table rendered, nothing else did. I also tried it in the HTML macro but that also failed.

Please forgive my ignorance, but how do you actually use this?

Cheers.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events