Dashboard updates - template hacking to add more information?
Asked by Sam Hall:

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>


Answers:
author: Sam Hall
body: 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('&lt;li class="update-item"&gt;&lt;div class="update-item-icons"&gt;', (opt_data.changeItem.thumbnailable) ? '&lt;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"&gt;&lt;/a&gt;' : '&lt;span class="update-item-arrow"&gt;&lt;/span&gt;');      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('&lt;/div&gt;&lt;div class="update-item-content"&gt;&lt;span class="update-item-title"&gt;', opt_data.changeItem.html, '&lt;/span&gt;');      if (opt_data.changeItem.spaceName != undefined) output.append('&amp;nbsp;&lt;span class="smalltext"&gt;(', soy.$$escapeHtml(opt_data.changeItem.spaceName), ')&lt;/span&gt;');      output.append('&lt;span class="update-item-date"&gt; ', soy.$$escapeHtml(opt_data.changeItem.updateDescription), '&lt;/span&gt;', (opt_data.changeItem.viewChangesLink) ? '&lt;span class="update-item-changes"&gt;(&lt;a href="' + soy.$$escapeHtml(opt_data.changeItem.viewChangesLink) + '"&gt;' + soy.$$escapeHtml("view change") + '&lt;/a&gt;)&lt;/span&gt;' : '', (opt_data.changeItem.summary) ? '&lt;p class="update-item-summary"&gt;' + soy.$$escapeHtml(opt_data.changeItem.summary) + '&lt;/p&gt;' : '', (opt_data.changeItem.thumbnailable) ? '&lt;div class="update-item-thumbnail-container"&gt;&lt;a href="' + soy.$$escapeHtml(opt_data.changeItem.imageUrl) + '"&gt;&lt;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" /&gt;&lt;/a&gt;&lt;/div&gt;' : '', '&lt;/div&gt;&lt;/li&gt;');      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 &gt; ul.tabs-menu &gt; 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);  }});
```


Tags: theme