Find pages without labels

Hi out there,

is there an easy way to find all pages without a label? I know there is a macro for content by label and it is possible to exclude labels but right now we have nearly 160 labels and I do not want to add them all to the macro.

Thanks,

Bruce

1 answer

1 accepted

This is possible by writing a usermacro that iterates over all spaces and its pages searching for pages without a label. But such a usermacro will slow down your system dependent on how big your confluence instance is. Such a macro should only be shortly used by an administrator.

Here is the usermacro code.

## @noparams

## DO NOT USE THIS MACRO ON A LOT OF PAGES BECAUSE OF PERFORMANCE ISSUES. IT DEFINITELY WILL SLOW DOWN YOU SYSTEM!!!!!

#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')) 

## the spaceManager gives you access to the spaces
#set($spaceManager =$containerContext.getComponent('spaceManager')) 
  
##over all spaces (WARNING THIS COULD TAKE SOME TIME ON BIG CF INSTANCES )
#foreach( $space in $spaceManager.getAllSpaces() )   

    <b>Unlabeled pages in space $space.name<b>
    <ul>
    ##over each page in the current space ( WARNING THIS COULD TAKE SOME TIME ON BIG CF INSTANCES)
    #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>
#end

Testet with my Confluence 4.0.

Thanks, I will try that

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,077 views 17 14
Join discussion

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