Hi All,
I would like to get a list which display on which pages a user macro is in use in Confluence. Is there a such macro or feature?
Thanks for your help!
Rumi
There are two plugins you could use for to achieve what you're after:
Please note that none of the above plugins are compatible with Confluence 4.x.
Hi Rumi,
if it is a specific user macro you are searching for, you can find it by its name. Simply search for:
macroName: <macroname>*
and replace <macroname> with the name of the macro you are searching for. Note that the capitalization, space after the colon, and the star at the end are all necessary.
More information can be found here: http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's a macro to do it:
## Macro title: Macro Usage Report ## Developed by: Matthew J. Horn ## Date created: 11/12/13 ## This macro takes no parameters ## @noparams ## Get a list of User Macros #set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager')) #set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null)) #set($containerManager = $getInstanceMethod.invoke(null,null)) #set($containerContext = $containerManager.containerContext) #set($macroManager = $containerContext.getComponent('userMacroLibrary')) #set($macroMetadataManager = $containerContext.getComponent('macroMetadataManager')) #set($macroNames = $macroManager.getMacroNames()) ## Get the ExcerptHelper (probably not supposed to be used for getting all macros, but it works) #set($eHelper = $containerContext.getComponent('excerptHelper')) ## Get a list of pages in the space #set ( $targetSpace = $spaceManager.getSpace("demo") ) #set ( $allPagesInSpace = $pageManager.getPages($targetSpace, true) ) ## List all macro names <h3>Macro names</h3> <hr/> #foreach($name in $macroNames) $name, #end #set($isValid = false) ## Iterate over each page and check if each of the macros in macroNames is used on that page <h3>Macro Usage</h3> <hr/> <table> <tr><th>Macro</th><th>Description</th><th>Page (isValid) (parameters)</th></tr> #foreach ($name in $macroNames) <tr> <td>$macroMetadataManager.getMacroMetadataByName($name).getTitle().getKey() ($name)</td> <td>$macroMetadataManager.getMacroMetadataByName($name).getDescription().getKey()</td> <td> #foreach ($page in $allPagesInSpace) ## $page is of type Page #if ($eHelper.getMacroDefinition($page, $name)) <a href="$page.getUrlPath()">$page.getTitle()</a> ($eHelper.getMacroDefinition($page, $name).isValid()) ($eHelper.getMacroDefinition($page, $name).getParameters())<br/> #end #end </td> </tr> #end </table>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The page column will be empty if there are no macros of that type in any of the pages. You're currently using "user macros" in the space that you're searching?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.