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

How to count all pages with a given label in a space?

Nicolai Willers September 4, 2015

Hi!

I'm using Confluence 3.4.9 and I need to know how I could count all pages within a given space that share a specific label (something like "contentbylabel" combined with a counter).

A user macro would be perfect.

Any help?

 

Thanks a lot in advance.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Stephen Deutsch
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.
September 4, 2015
## @param ParentPage:title=Page|type=confluence-content|required=true|desc=Select a page for which to count the children
## @param Label:title=label|type=string|required=true|desc=Specify a label to count
#set($pageCount = 0)
#set ( $colonIndex = $paramParentPage.indexOf(":") )
#if ( $colonIndex == -1 )
  #set ( $parentSpaceKey = $space.key )
  #set ( $parentPageName = $paramParentPage )
#else
  #set ( $parentSpaceKey = $paramParentPage.substring(0, $colonIndex) )
  #set ( $parentPageNameIndex = $colonIndex + 1 )
  #set ( $parentPageName = $paramParentPage.substring($parentPageNameIndex) )
#end
#set ( $parentPage = $pageManager.getPage($parentSpaceKey, $parentPageName) )
#foreach( $child in $parentPage.descendents )   
  #foreach( $childlabel in $child.labels )   
    #if($childlabel.name == $paramLabel )
      #set($pageCount = $pageCount +1)
    #end
  #end
#end
<p>Under $parentPageName there are $pageCount pages with the label $paramLabel</p>
0 votes
Nicolai Willers September 4, 2015

Hi Rodrigo,

 

unfortunately it does not. I am not allowed to install the reporting plugin an the macro shown only counts the children of the CURRENT page. 

Can you modify the macro to count children of a specific page (that have a specific label)?

Thanks in advance.

 

0 votes
Rodrigo Girardi Adami
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 4, 2015

Hi Nicolai,

I could find this answer which contains some examples of usermacros to count pages given a specific parent page.

I hope this helps!

Cheers,

Rodrigo

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events