Dashboard updates - template hacking to add more information?

We used to have RefinedWiki theme installed until recently. I'm pretty sure that theme displayed the space name for each update listed on the Dashboard.

Is there any way I can add the space to update items in the default Confluence theme?

If so, can someone please point me to the file I need to customise? I've looked at this document here which gives me the clue that it may be possible... https://confluence.atlassian.com/display/CONF42/Customising+the+Dashboard#CustomisingtheDashboard-Modifyingtheglobaltemplateorlayout

1 answer

1 accepted

It seems like this is fully generated by the recently-updated-dashboard macro, and the HTML is rendered by some javascript that doesn't appear to be template driven (at least not using those .vm templates anyway). I managed to override the function that renders each update item and force it to refresh the list on page load to bring in the space name by adding this script with the altered function to our Custom HTML...

AJS.toInit(function(){

// Override update item template to include Space Name
  Confluence.Templates.Dashboard.Updates.updateItem_old = Confluence.Templates.Dashboard.Updates.updateItem;
  
  Confluence.Templates.Dashboard.Updates.updateItem = function(opt_data, opt_sb) {
    try {
      var output = opt_sb || new soy.StringBuilder();
      output.append('<li class="update-item"><div class="update-item-icons">', (opt_data.changeItem.thumbnailable) ? '<a id="twixie-' + soy.$$escapeHtml(opt_data.changeSetNumber) + soy.$$escapeHtml(opt_data.changeItemNumber) + '" href="" data-thumbnail-id="' + soy.$$escapeHtml(opt_data.changeSetNumber) + soy.$$escapeHtml(opt_data.changeItemNumber) + '" class="update-item-arrow icon icon-section-closed"></a>' : '<span class="update-item-arrow"></span>');
      Confluence.Templates.Icons.contentIcon({content: opt_data.changeItem.entity, iconTitle: opt_data.changeItem.friendlyContentType, iconCss: opt_data.changeItem.iconCss, linkHref: opt_data.changeItem.urlPath}, output);
      output.append('</div><div class="update-item-content"><span class="update-item-title">', opt_data.changeItem.html, '</span>');
      if (opt_data.changeItem.spaceName != undefined) output.append(' <span class="smalltext">(', soy.$$escapeHtml(opt_data.changeItem.spaceName), ')</span>');
      output.append('<span class="update-item-date"> ', soy.$$escapeHtml(opt_data.changeItem.updateDescription), '</span>', (opt_data.changeItem.viewChangesLink) ? '<span class="update-item-changes">(<a href="' + soy.$$escapeHtml(opt_data.changeItem.viewChangesLink) + '">' + soy.$$escapeHtml("view change") + '</a>)</span>' : '', (opt_data.changeItem.summary) ? '<p class="update-item-summary">' + soy.$$escapeHtml(opt_data.changeItem.summary) + '</p>' : '', (opt_data.changeItem.thumbnailable) ? '<div class="update-item-thumbnail-container"><a href="' + soy.$$escapeHtml(opt_data.changeItem.imageUrl) + '"><img id="thumbnail-' + soy.$$escapeHtml(opt_data.changeSetNumber) + soy.$$escapeHtml(opt_data.changeItemNumber) + '" class="thumbnail" src="' + soy.$$escapeHtml(opt_data.changeItem.thumbnailUrl) + '" width="' + soy.$$escapeHtml(opt_data.changeItem.thumbnailWidth) + '" height="' + soy.$$escapeHtml(opt_data.changeItem.thumbnailHeight) + '" style="display: none" /></a></div>' : '', '</div></li>');
      return opt_sb ? '' : output.toString();
    } catch(e) {
      return Confluence.Templates.Dashboard.Updates.updateItem_old(opt_data, opt_sb);
    }
  };
  
// Hack to refresh the updates list...
  var activeTab = AJS.$('#recent-updates > ul.tabs-menu > li.menu-item.active-tab');
  var targetLink = activeTab.find('a');
  if (targetLink.length == 1) {
    var backupHref = targetLink.attr("href");
    activeTab.removeClass("active-tab");
    // Try and avoid any possibility of a redirect loop...
    targetLink.attr("href","javascript:void(0)");
    targetLink.click();
    targetLink.attr("href",backupHref);
  }
});

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,777 views 26 10
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