Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Dashboard updates - template hacking to add more information?

Sam Hall
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.
March 18, 2013

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

0 votes
Answer accepted
Sam Hall
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.
March 18, 2013

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
TAGS
AUG Leaders

Atlassian Community Events