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

User macro for counting multiple labels on pages

Deleted user May 7, 2021

I've got this piece of code to count pages with a certain label in a certain space

## To count labels
## @param Label:title=Label|type=string|required=true|desc=Enter a label to count.
## @param Spaces:title=Space|type=string|required=false|desc=This Key is case-sensitive. Only for use in one single space. Example: SPACEKEY

#set( $labelManager = $action.LabelManager )
#set( $labRef = $labelManager.getLabel($paramLabel) )
#set( $pages = $labelManager.getCurrentContentForLabelAndSpace($labRef, $paramSpaces) )

$pages.size()

 I would really like to filter on, multiple labels (in AND and OR) anyone knows how?

Any help is appreciated

Thank you.

 

1 answer

0 votes
Dominic Lagger
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.
May 10, 2021

Hi @[deleted] 

I know the answer for the "AND", but not for the "OR"

#set( $list = $labelManager.getContentInSpaceForAllLabels(0, 10, $paramSpaces, $labRef, $labRef2)) 

See documentation.

With this statement, you get a list of all pages in the space with the labels from $labRef AND $labRef2. Because it's this type of parameter (Label... labels) you can add as much labels you want.

The only thing I can imagine for "OR" would be to search with CQL, but this is a bit tricky (Don't know how)

Regards, Dominic

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events