Is there a way to display the label field onto a page properties report in confluence?
Asked by suzanne.potter:

I'd like to display in the page properties report the label assigned to a page in the Decision log. I see there is a way to display a label when using the content by label macro. In that macro there is a choice to display a label (show labels for each page). I do not see a way to display a label in the page properties report macro. Our users would like to see the label as a column to see as well as sort by. We make many decisions on our project and are using the decisions log to track our decisions. We want to categorize our like decisions and be able to see and sort by those categories. We are trying to use labels as a way to categorize our decisions.


Answers:
author: Diego
body: Hello there!

Suzanne, you should be able to achieve this indeed. We will need to create a **User macro**. Here, let us start by creating the user macro:

**Creating this user macro:**
> 1. Click the **Cog Icon** ![](https://confluence.atlassian.com/doc/files/747833194/747833195/2/1517274813281/cog.png) \> **General Configuration** \> **User macros**.
> 2. Once there, click **create a user macro** right at the bottom
> 3. Under **macro name**, type a name for your macro (label-list for example)
> 4. Select the desired macro visibility
> 5. Type a **macro title** (Label List in our case)
> 6. Select **No Macro Body**
> 7. Inside the **Template field** , paste this code:  
>    1.
>
>       ```
>       ## @noparams
>       #set($currentPage = $pageManager.getPage($content.getId()))
>       #set($pageLabels = $currentPage.getLabels())
>       <span>
>       #foreach( $labelObject in $pageLabels )
>       <span class="aui-label">$labelObject.name</span>
>       #end
>       </span>
>       ```
>
> 8. Save

After the macro is created, we will then need to insert it into a Page Properties macro. Here is how mine looks like:

![Screen Shot 2019-04-10 at 14.48.40.png](https://community.atlassian.com/t5/image/serverpage/image-id/51155iA5AB0CCB02528A47/image-dimensions/534x248?v=v2 "Screen Shot 2019-04-10 at 14.48.40.png")

As you can see, the page labels are displayed within the table I created for the Page Properties macro with no problem. Now, when we use the Page Properties Report macro, my labels look like this:

![Screen Shot 2019-04-10 at 14.49.10.png](https://community.atlassian.com/t5/image/serverpage/image-id/51156i4DA6C1B414D3AF03/image-dimensions/557x78?v=v2 "Screen Shot 2019-04-10 at 14.49.10.png")

**Notes:**

* You need to be an instance admin to create user macros

So, let us know if this helps you out Suzanne!

comments: author: Emanuele Festa
body: Hello,

This user macro works very well thanks.

Would it be possible to add to this macro the feature to hide some labels? In the Page Properties Report some pages are labeled as "favourite", and there is also the label I use to gather the pages in the Page Properties Report.

thanks!


author: Dan Turner
body: As someone who is not an admin but sees this ability to list a label in Page Properties as a perfect solution to a big need we have (basically, a way to provide detailed info and faceted browsing in a list or table format), please incorporate this ability to the regular macro!

comments: author: Daniel Barth
body: I strongly second this request. Would be most helpful in a variety of use cases for us.


author: Niranjan
body: The macro stopped to work after our Confluence upgrade to 7.19.x. Then made a small change to make it work again.

1.

   ```
   ## @noparams
   #set($currentPage = $pageManagerInternal.getPage($content.getId()))
   #set($pageLabels = $currentPage.getLabels())
   <span>
   #foreach( $labelObject in $pageLabels )
   <span class="aui-label">$labelObject.name</span>
   #end
   </span>
   ```

comments: author: Antoine _Klee Group_
body: Hi [@Niranjan](/t5/user/viewprofilepage/user-id/715719) thanks for your contribution, I have the exact same need as op!

I'm on Confluence version 7.19.7 and copied your code but it do not seem to work.

Is it really working fine on your side?


Tags: cloud

confluence-cloud