Is there a way to get a list of pages within a space, and their associated labels?

We have about 100 "content" pages in a space (today). When we create "content" pages, we are supposed to attach 4 labels and keep them updated, and then I have "grouping" pages that use the "Page Properties report Macro" to display "content" pages matching a specific label.

 

The issue and risk I am finding is that it's possible that if labels aren't updated (or even worse, were never attached), "content" pages could get lost if they never show up in the "grouping" pages.

 

Is there a way to see any of these lists?:

  • all pages in a space that do not have a label
  • all pages in a space that does not have one of these labels (Label_a, Label_b)
  • all pages in a space, with their labels listed beside them
  • all pages in a space, with their labels and page properties 

Thank you.

We're using Confluence 5.5.2.  

1 answer

1 accepted

0 votes
Answer accepted
  1. I was able to create a User Macro to display all pages in the space that do not have a label.  Here is the code:

    ## @noparams
    #set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager'))
    #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
    #set($containerManager=$getInstanceMethod.invoke(null,null))
    #set($containerContext=$containerManager.containerContext)
       
    ## the pageManager gives you access to the pages
    #set($pageManager =$containerContext.getComponent('pageManager'))
     
       
        <b>Unlabeled pages in space $space.name<b>
        <ul>
        #foreach( $page in $pageManager.getPages( $space, true) )  
     
            #if( $page.labels.size() == 0 )
                   <li><a href="$req.contextPath$page.urlPath">$page.title</a></li>
            #end
        #end
        </ul>
  2. I was able to create a User Macro to display all pages in the space and their associated labels.

    ## @noparams
    #set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager'))
    #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
    #set($containerManager=$getInstanceMethod.invoke(null,null))
    #set($containerContext=$containerManager.containerContext)
       
    ## the pageManager gives you access to the pages
    #set($pageManager =$containerContext.getComponent('pageManager'))
     
       
        <b>Pages in space $space.name and their associated labels.<b>
        <ul>
        #foreach( $page in $pageManager.getPages( $space, true) )  
     
              <li><a href="$req.contextPath$page.urlPath">$page.title</a> - $page.labels</li>
        #end
        </ul>

 

 

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

406 views 2 13
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you