...or how to display attachments in an unordered list.
Something that bugs me in Confluence is the way that attachments are shown. The default view is a big table with just about all the information related to each attachment.
This is great if you want all this detail, but I'm a simple soul with simple needs.
Krug suggested "Omit needless words". In this case, it's more of "Omit needless metadata".
Less is more
Enter {list-attachments} - a user macro that dispenses with the excess. It displays an unordered list with the filename, file size and last modified date. If there's a comment for the attachment, this is displayed in the link text rather than the filename.
This is a really straightforward view of the attachments on the page.
How do I install {list-attachments} ?
It's pretty easy. As a Confluence administrator, go to Confluence Admin | User Macros and click on Create a User Macro.
Macro name: list-attachments
Template:
## MACRO: list-attachments
## Updated: 2014-05-12
## View page attachments in a simple list
## USAGE: {list-attachments}
## @noparams
#set ($attachmentsList = $content.getLatestVersionsOfAttachments())
#if ($attachmentsList.size() > 0)
<ul>
#foreach( $attachment in $attachmentsList )
#set ($currentAttachmentId = $attachment.id)
#if ($attachment.comment && $attachment.comment.trim().length() > 0)
## Display the comment as the link text instead of the filename
<li><a href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.comment)</a></li>
#else
## Display the filename as the link text
<li><a href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.fileName)</a></li>
#end
#end
</ul>
#end
Accept the defaults for the other fields, then click on Save
To call the macro in the page type: {list-attachments}
The result:
Now you're left with a simple list of links — much purer than a big fat table of metadata.
For extra points (Updated 2011-03-15)
If you've got a might great slab of files attached to the Confluence page, why not wrap this usermacro in the azList macro:
{azlist}{list-attachments}{azlist}
The result: