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

Is it possible to display some page labels but not others on a page?

Michelle Rau good
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.
October 31, 2019

I wonder if there is a macro or some other method to display some of a page's labels and exclude others. For example, if a page has labels book, drama, and historical, I only want to display drama and historical since it's already clear from context that this is a book.

I have been using the Page Info macro to list labels, and sometimes the Report Info macro from ServiceRocket's Reporting plugin. Neither one has an option to list some labels but not others.

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 7, 2019

Hi @Michelle Rau good ,

There is no macro available out of the box to achieve what you are asking for, however, this can be done with a User Macro.

I have create the below one as an example and it works fine on my test instance.  

## Macro title: page-labels-not-in-list
## Macro has a body: N
## Developed by: Dario
## Date created: 7/11/2019
## Installed by: Dario

## @param Label:title=Label|type=string|required=true|desc=List of labels comma separated

#set($labelList = $paramLabel.split(","))

<h2>List all labels for the page, excluding: $paramLabel </h2>
<br />
<span>

#foreach($pageLabel in $content.getLabels())
#set($found = 0)
#foreach ($label in $labelList)
#if($pageLabel == $label)
#set($found=1)
#end
#end

#if($found == 0)
<span class="aui-label">$pageLabel</span>
#end

#end

</span>

 

Can you kindly test it and confirm it works for you as well?

 

Cheers,
Dario

Michelle Rau good
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.
November 7, 2019

Oooh! I will ask our wiki admins if we can test this.

In the meantime, can you paste a snapshot of what this looks like on a page? That will help me describe to them what it does.

Thank you!

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 8, 2019

Hi @Michelle Rau good ,

Please notice that I just provided a very easy example of a user macro that prints all the labels from the current page, excluding the ones provided in input. 

As it is, the macro is just writing a line of text followed by the list of labels (excluding the ones configured as the input for the macro):

labels-not-in-list-usr-macro.jpg

 

You will have to extend and modify the according to your needs.

You can also modify the way this looks by using JavaScript and CSS. See below documentation for details on how to do so:

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events