Does Confluence have a plugin or macro that shows 'Where Used' information?

Does Confluence have a macro or plugin that allows you to post a listing of where an article is reference in other articles?  I'd like to create a definitions/ acronym listing, and a "Where Used" capability similar to that found in MediaWiki would be useful to show where the terms are being used elsewhere in the library.

2 answers

1 vote
Davin Studer Community Champion Nov 30, 2015

Not sure I totally understand what you are asking, but are you looking for a referring content macro? If so here is a user macro that will do that. If that is not what you are asking then sorry.

Update: Added title, show title, and hide on include parameters.

Macro Body Processing:
No macro body 

Template: 

## Developed by: Davin Studer
## Date created: 06/26/2014
## @param Title:title=Title|type=string|required=false|default=Referring Content|desc=The title for the list.
## @param ShowTitle:title=Show title|type=boolean|required=false|default=true|desc=Show the "Pages that link here" title for the list.
## @param Hide:title=Hide on include|type=boolean|required=false|default=true|desc=If this page is included on another page then hide the referring content links.
 
#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($linkManager=$containerContext.getComponent('linkManager'))
 
#set ($d = '$')
#set ($pages = $linkManager.getReferringContent($content))
 
#if($pages.size() > 0)
    #if($paramShowTitle == true && $paramTitle && $paramTitle != "")
<p id="referring-content-title$content.id" class="referring-content-links-title">$paramTitle</p>
    #end
<ul id="referring-content-page$content.id" class="referring-content-links" style="display: none;">
    #foreach($page in $pages)
        #if (!$page.isDeleted())
    <li><a href="$page.getUrlPath()">$page.getTitle()</a></li>
        #end
    #end
</ul>
#end
 
<style type="text/css">
.referring-content-links-title {font-weight: bold;}
</style>
 
<script type="text/javascript">
AJS.toInit(function() {
    var hideOnInclude$content.id = $paramHide;
    var originalPage$content.id = '$content.id';
    
    if(hideOnInclude$content.id && originalPage$content.id != AJS.params.pageId) {
        AJS.${d}('#referring-content-page${content.id}').css('display', 'none');
    } else {
        AJS.${d}('#referring-content-page${content.id}').css('display', 'block');
    }
});
</script>

This works great; thank you Davin! The only thing I'd like to see is a checkbox to hide the results from where the page is used as an include, or hide from view completely. I just used the Page Properties macro which has a Hide checkbox to keep it from appearing, and since the results are listed when editing the user macro, the report is just what I needed.

Davin Studer Community Champion Dec 02, 2015

I'm not quite understanding what you are asking in regards to the checkbox.

So I have a snippet that I use in an Include Page macro on another page, if that snippet page includes your Referrer Report user macro (as I call it), then the list of pages produced by the user macro also appears on the page using the Include Page macro. I would like the list of pages to NOT show up when the containing page is included elsewhere. I suppose I could put the snippet text into an Excerpt macro and use the Include Excerpt macro instead of the Include Page macro; it would just take time to redo all the reusable content.

Davin Studer Community Champion Dec 02, 2015

Ah got it. Hmm ... off the top of my head I'm not sure there would be a way to code that into a user macro. I'll give it some thought, and see if I can work something up.

Davin Studer Community Champion Dec 02, 2015

Ok. I think I've worked something up that should work. I've edited the above code.

Brilliant! One last humble request; the option to display a title of the report: Even a static "Pages that link here" so that it's clear what the list represents.

Davin Studer Community Champion Dec 02, 2015

K. Edit is above.

Nice! But I think Hide on include should hide the title too.

Unfortunately, I am not a Wiki developer, but rather a Wiki user/author, so I'm looking more for a canned technology added to the "Insert More Content" | "Other Macros" toolbar in Confluence. I wouldn't know what to do with raw code.

Davin Studer Community Champion Dec 03, 2015

Once this is added as a user macro by a system admin it will show up in the macro browser as a regular macro.

0 vote
Stephen Deutsch Community Champion Nov 30, 2015

Last I checked, there is an "incoming-links" macro as part of the Confluence Linking plugin: https://marketplace.atlassian.com/plugins/net.customware.confluence.plugin.linking/server/overview

Don't forget you need to get the free license from ServiceRocket before using it (you can find a link under "Documentation" on the Marketplace page).

No, not looking for incoming-links, but rather outgoing links. 'What links here?' is another term I've seen. For example, I could create a Wiki article titled "verification" where we define the term "verification". Other articles can reference the verification article in the body of the text. At the bottom of the "verification" article, you can add a "Where Used/What Links Here" macro that shows articles where "verification" was referenced. It's an interesting technique of threading articles together via a glossary. Especially useful for acronym listings.

Davin Studer Community Champion Dec 01, 2015

The user macro I provided below will do what you want. It will show you referring links (pages that link to the current page). This will obviously only work for wiki links. Anything external to the wiki or links in the wiki created as "Web Links" won't show.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted yesterday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

59 views 2 2
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