Add a link to the status macro

Is it possible to add a link to the Status macro in Confluence?

2 answers

No, but using User Macros you could write your own and adding in the functionality.

You can find the VTL code for a version (I'm not sure how modern it is) for the code here: https://confluence.atlassian.com/display/CONF34/Writing+the+Status+User+Macro.

  1. You can write it and then add a parameter for a link.
  2. When the user enters something in that field you could have it generate an <a> tag around the lozenge that points to the URL mentioned.

We wanted to do this and came up with a jQuery based solution. It works well for us, as the coding is hidden from users in a page template. The gist of it is to define the link you want to apply in the normal way, but inside a "div" element (thanks to the Adaptavist Content Formatting macros plugin). This div has its style property set to display:none, so is invisible when the page is viewed normally. The jQuery code looks for this link and applies it to a status macro, based on the text that has been set for it.

Why go to the trouble of making a hidden link in this way? Since it relies on the normal Confluence functionality to do this, I see benefits if the target page was to undergo a change of name. In other words, we're not hard-coding the link.

Here's some sample code. If you have the plugin I mentioned and the html macro enabled in your environment, then just put this directly into a test page and you should see it works nicely. Note - the link is put on the entire status box, not just the text within it.

{div:statusboxes}
{status:colour=Green|title=Wiki User Guide}
{div}

{div:userguidelink|style=display: none;}
&lt;Your link here&gt;
{div}

{html}
&lt;script type="text/javascript"&gt;
  jQuery(document).ready(function() {

    // Add links to status boxes
    jQuery('#statusboxes span:contains(Wiki User Guide)').hover(function(event) {    
      jQuery(this).css( 'cursor', 'pointer' );
    });
    jQuery('#statusboxes span:contains(Wiki User Guide)').click(function(event) {
      window.location = jQuery('#userguidelink a:first').attr('href');
      return false;
    });

  });
&lt;/script&gt;
{html}

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,563 views 26 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