It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

Hi @Michelle_Rau ,

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

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!

Hi @Michelle_Rau ,

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
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

327 views 9 7
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you