Find pages without labels

Bruce Schlueter November 24, 2011

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

0 votes
Answer accepted
Sandro Herrmann [Communardo]
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 25, 2011

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.

Bruce Schlueter November 25, 2011

Thanks, I will try that

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events