Add a link to the status macro

Chris Flynn May 21, 2013

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

2 answers

0 votes
CharlesH
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.
May 22, 2013

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;}
<Your link here>
{div}

{html}
<script type="text/javascript">
  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;
    });

  });
</script>
{html}

0 votes
Steve Goldberg
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.
May 21, 2013

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events