How to get the amount of pages with a certain label in Conflunce?

Is it possible without SQL?

I would like to use a plugin or existing Confluence functionality. 

3 answers

1 accepted

This widget could not be displayed.

I happen to have written a user macro to do this:

 

## Macro title: Count Labels
## Macro has a body: N
## Developed by: Jonathan Simonoff
## Date created: 8/12/13
## Installed by: Jonathan
## To count labels
## @param Label:title=Label|type=string|required=true|desc=The label to count
## @param Spaces:title=Spaces|type=string|required=false|desc=These are case-sensitive. Separate each item with a comma or single space. Example: SPACEKEY,@personal.  Blank means all spaces. 
#set($helper=$action.getHelper())
#set($pages=$helper.renderConfluenceMacro("{contentbylabel:labels=$paramLabel|showLabels=false|max=99999999|spaces=$!paramSpaces}"))
#set($pagelist=$pages.split("<li>"))
#set($count=-1)
#foreach($page in $pagelist)
 #set($count=$count+1)
#end
$count

Should this macro work with all Confluence versions? Because it doesn't seem to work with version 5.9.10. On our Confluence installation I get this error:

Error formatting macro: contentbylabel: com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql : null

Any ideas?

Regards, Marc

This widget could not be displayed.

You could use Confluence search like this: 

labelText:chocolate

See also: https://confluence.atlassian.com/display/DOC/Confluence+Search+Syntax#ConfluenceSearchSyntax-Searchingforlabels

This widget could not be displayed.

Thanks Lucas and Jonathan. The macro works like a charm

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

477 views 6 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you