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

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

Eduardo Llanos January 19, 2015

Is it possible without SQL?

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

3 answers

1 accepted

1 vote
Answer accepted
Jonathan Simonoff
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.
January 19, 2015

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
Marc Dvorschak
Contributor
November 21, 2016

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

Ashwin Somani June 23, 2023

Hi  Jonathan ,

Is this macro only work with label which are having single word like "testing", doesn't work with the label like "testing-ashwin" or "testing ashwin".

It is giving this error when i am trying this - 

Capture.PNG

Vivek Lakshman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 30, 2023

Hi @Jonathan Simonoff ,

Could you please check the above query and let us know why are we getting that error?

Ashwin Somani July 5, 2023

Hi @Jonathan Simonoff 

Could you check this or is this really not possible. Thanks!

1 vote
Lukas Knoch -Rumpelcoders-
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.
January 19, 2015

You could use Confluence search like this: 

labelText:chocolate

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

0 votes
Eduardo Llanos January 19, 2015

Thanks Lucas and Jonathan. The macro works like a charm

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community events, ace, engineering, confluence feed, power of feed, atlassian ask me anything, atlassian confluence answers, ace rsvp, atlassian community events rsvp, atlassian magic

“How We Built This” ft. Atlassian Confluence Engineers

Meet the engineers who are making the Confluence magic happen at Atlassian ✨

RSVP now!
AUG Leaders

Upcoming Confluence Events