Hi,
does anyone know a nice way to search Confluence for pages that use a given macro?
This would help to see which plugins are widely used or who is using certain plugins.
We could use this information to contact the plugin users directly or to see which plugins are no longer required and could be removed.
Regards,
Stephan
For people who don't have access to the database, here's how to do it in Confluence 4.0 and above:
http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/
In a nutshell: In a nutshell: Enter the following in the Confluence search box, assuming that your macro name is “x”:
macroName: x*
The above works in out-of-the-box Confluence (no plugins required). If you install a plugin, you can also search for specific parameters and parameter values. See http://ffeathers.wordpress.com/2012/09/04/how-to-search-for-macros-and-macro-parameters-in-confluence-4/
I hope this helps!
Cheers, Sarah
I tried that, but I always get this response: "Did you mean: mucronate:sql*"
when searching for macroName:sql* (tried with or without a space after : )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo Andre
Which version of Confluence are you using? The "macroName" search field is available in Confluence 4.0 and later.
In Confluence 3.5 and earlier, you can enter the curly brackets and the macro name surrounded by double quotation marks, like this:
“{sql”
More details in this post: http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/
Cheers, Sarah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe it's cace sensative i.e. it has to be "macroName: SearchString*"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This worked perfectly for us! We had migrated to Confluence 5.0 (we were on OnDemand). The JIRA macro could not be converted correctly. This saved us a ton of time by locating the pages and making the updates manually -- we had started down the path of reviewing every page for the problem until we came across this. Thanks!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great answer Sarah. What if I can't fined the exact macro name to use in the search? For example we're using the Customware Visibility plugin. But when i search for 'macroName:show-if' the result is 0, and i know that it's used. Any tips?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It does show "did you mean.." etc, but it still presents the results for what you asked for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I use that search, for either macroName:sql* or macroName:sql-query, I get exactly one result, even though I have dozens of pages using this macro. It only seems to find the outer macro, and almost all of my sql-query macros are wrapped in a run query.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm. For me it seems to work sometimes, sometimes not. I can also find macroName: excerpt-include*. But searching for the "Page properties" macro doesn't work. Can the blank in the macro name be the problem?
I tried:
macroName: page*
macroName: page properties
macroName: "Page properties"
...
I found pages, but that seems to be not connected to what I search.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found out, how to get the macro names. If you want to find it you have to look at the page in storage format (... menu of the page). There you can see the real names by searching (Ctrl-f) for "ac:structured-macro ac:name".
Then you find that the page properties macro has the "intuitive" name "details".
Another successful Atlassian way to impede their users by hiding information. Of course none of them every will read these community issues and improve anything. They just sit and count their money.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was using the usage macro in the confluence 4.0. it installs and runs but, has always been slow and causes the server to hang up while running. What we have since done is borrowed and tweaked the sql it was running, and run it directly against the sql server. The code will check in pages and blogpost where the content is the current version and not deleted. I will return a contentid, page title, the space id, the creator, and when it was modified. We use the following code:
Select CONTENT.CONTENTID, Title, SpaceID, CREATOR, LASTMODDATE from CONTENT, BODYCONTENT WHERE PREVVER IS NULL AND (CONTENTTYPE = 'PAGE' OR CONTENTTYPE = 'BLOGPOST') AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID AND CONTENT_STATUS = 'current' AND (BODY like '%{macro%')
Opps that code works for un converted macros in confluence 4.
For converted macros replace the last line with
AND (BODY like '%<ac:macro ac:name="MACRO">%')
You can go straight to a page by using this link and replacing CONTENTID with the returned contentid from the sql results https://confluence-install/pages/viewpage.action?pageId=CONTENTID
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Change "CONTENTID" to "CONTENT.CONTENTID"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
works perfectly Jason - many thanks for the advice!
Select CONTENT.CONTENTID, CONTENT.Title, CONTENT.SpaceID, CREATOR, LASTMODDATE from CONTENT, BODYCONTENT WHERE PREVVER IS NULL AND (CONTENT.CONTENTTYPE = 'PAGE' OR CONTENT.CONTENTTYPE = 'BLOGPOST') AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID AND CONTENT.CONTENT_STATUS = 'current' AND (BODYCONTENT.BODY like '%{cache%')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm running confluence 4.2.x and this works for me:
Select CONTENT.CONTENTID, CONTENT.Title, CONTENT.SpaceID, CREATOR, LASTMODDATE from CONTENT, BODYCONTENT WHERE PREVVER IS NULL AND (CONTENT.CONTENTTYPE = 'PAGE' OR CONTENT.CONTENTTYPE = 'BLOGPOST') AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID AND CONTENT.CONTENT_STATUS = 'current' AND (BODYCONTENT.BODY like '%{cache%')
EDIT: Andre beat me to it :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried running this (on mysql 5.0.95):
Select CONTENTID, Title, SpaceID, CREATOR, LASTMODDATE from CONTENT, BODYCONTENT WHERE PREVVER IS NULL AND (CONTENTTYPE = 'PAGE' OR CONTENTTYPE = 'BLOGPOST') AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID AND CONTENT_STATUS = 'current' AND (BODY like '%<ac:macro ac:name="MACRO">%')
but then I get a 'ERROR 1052 (23000): Column 'CONTENTID' in field list is ambiguous' message from mysql.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jason's SQL is the method to use when looking for a macro that is not working. For example, Graphviz recently became commercial and our existing pages using it now fail.
macroName:flowchart
does not work but the SQL method does. We needed it to answer the question: How many pages were using this plugin and should we buy it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On recent version of confluence (5.10+), it seems there is the usage of each macro, grouped by plugin, listed on this admin page:
https://%confluence%/admin/pluginusage.action
The SQL queries were good, but they also returned some false positive (ex. if the macro name is used as a parameter of another macro, you will get a match on this page).
Gilles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very helpful!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! Works great in Cloud Confluence as well!
https://YourNameGoesHere.atlassian.net/wiki/admin/pluginusage.action
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Saved me a ton of time, thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But for us it is impossible that all have to become admins to see this. We need a possibility to find the used macros as normal users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We wrote a little user macro for this requirement to create an overview page. Please use this macro only for Confluence version 3.5.x and older. Futhermore the performance of that macro iss very bad. Use is with care.
## @param macroname:title=Macro Name|type=string #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')) #set($macroNameSplit = $parammacroname.split(",") ) #foreach( $space in $spaceManager.getAllSpaces() ) <ul> #foreach( $page in $pageManager.getPages( $space, true) ) #foreach( $macroName in $macroNameSplit ) #if( $page.content.contains("{$macroName" ) ) <li><a href="$req.contextPath$page.urlPath">$space.key:$page.title → $macroName</a></li> #end #end #end </ul> #end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're using Confluence 3.5.x and earlier, you can try out Usage Stats Macro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hanis,
thank you for the fast answer. I am about to upgrade from 3.5.x (right now). I have saved the list :)
Is there any way to do that with Confluence 4.x?
Regards,
Stephan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd also be interested in how to do this in confluence 4.x installation - a number of macros/plug-in I've used in the past have gone commercial and I'm being asked how widely they are being used in order to justify the purchase. Any 4.x suggestions woudl be most welcome.
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 that gets all macros used on all pages in a space. You can modify it to suit your needs (such as replacing the macroNames list with a single macro.
## 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 ## 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.
Matthew
How do I use this please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I added this Macro to user Macros and then created a page with this macro added in. I still do not get the list of Macros used on the space. Any ideas? I am using COnfluence 5.1.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is nice, but it should be clear, this only is for user macros.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
// then name of the app from $macro.getPluginKey()
...
function lookPlugin(pluginkey){
var html = '';
var searchURL = '';
AJS.$('#queryStatus span').text('Buscando plugin: ' + pluginkey);
searchURL = AJS.params.baseUrl + '/rest/plugins/1.0/' + pluginkey + '-key';
var nombrePlugin= 'hola';
AJS.${d}.ajax(
{
type: 'GET',
url: searchURL,
async: false,
dataType: "json",
timeout:60000,
success: function(data) {
nombrePlugin=data.name + '(' + data.version+ ')';
},
error: function (x, y, z) {
nombrePlugin= 'Other:' +pluginkey;
}
}
);
return nombrePlugin;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using:
macroName: Table-of-Contents*
or any variation of this name/format doesn't find the TOC macro. It works perfectly well on single words, but not at all on multi-worded titles.
We're using 4.3.7. Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the latest Confluence upgrades, you can no longer search macroName:JIRA Issues - it only locates those pages that have JIRA Issue
I submitted a support ticket and was told that this wasn't a bug as this was an unintended release of a feature. So, since it was not intended to be released, any issues are not bugs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've just tried this again in 5.4.3 Download and it still works in the way I've described above.
So: macroName: Code-Block* - doesn't find the macro (though it does find other things).
However: macroName: code* - finds all pages using the Code Block macro.
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
More info on this.
When I started searching it was from the global search field. However, I've also tried this in specific spaces AND in sets of sub-pages that use the Page Tree Search macro.
This means you can run the search on a very specific set of pages. HTHs.
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Any idea when this will be supported again in a latest version of Confluence? Is there a feature request already on this? Thanks. Pat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pat,
See my comments above, are they helpful?
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mikc, Kind of helps. Here's our scenario we are looking for a resolution or workaround if you know of one. If someone leaves the company, we'd like to be able to find references to them as used in macros such as the user-profile macro, so we can clean things up on pages. We have a work instruction for doing that, but the work instruction steps don't work anymore: we used to be able to do that with wiki markup but not in the new HTML5 format of Confluence. Any ideas? Thanks, Pat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well that's not very helpful is it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Most of these searches seem to be for searching the entire confluence wiki for a macro. What I would like is when editing a page, I would like to jump to the next instance of the macro while I am editing the page. Kind of like CTRL+F but instead of searching for text, search for a macro.
I have tried inserting macroName: Note* into the "Find" field when pressing CTRL+F but it did not seem to work. Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
bingo!
Gavin's query works!
Thanks to all for the help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.