How to modify the attachments macro in confluence?

We want to modify the attachments macro. There is the column "modified" in that macro that shows who and when the attachment was modified and we do not want this to be included in our table. We want a basic table that shows only the file names and users can download those files easily. Please let us know if there is any way to modify this macro.

2 answers

1 vote
Gregor Kasmann Community Champion Oct 21, 2017

You cannot modify this macro, but you can create your own "user macro" with the same functions.
Create new User Macro:

2017-10-21 23_21_26-Edit User Macro.png
Put macro source like this:

## @noparams
#set ($attachmentsList = $content.getLatestVersionsOfAttachments())
#if ($attachmentsList.size() > 0)
        #foreach( $attachment in $attachmentsList )
            #set ($currentAttachmentId = $
            #if ($attachment.comment && $attachment.comment.trim().length() > 0)
                <li><a href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.comment)</a></li>
                <li><a href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.fileName)</a></li>

Thank you very much Gregor! This is exactly what I was looking for.

0 vote

It would require re-coding and re-compiling the add-on that provides the macro to do this.

You could probably get close with a user macro though, instead of coding a new add-on

Thanks Nic for the info!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

787 views 23 12
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