How to modify the attachments macro in confluence?

Elnaz Beirami October 20, 2017

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

2 votes
Gregor Kasmann_Actonic
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.
October 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)
    <ul>
        #foreach( $attachment in $attachmentsList )
            #set ($currentAttachmentId = $attachment.id)
            #if ($attachment.comment && $attachment.comment.trim().length() > 0)
                <li><a href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.comment)</a></li>
            #else
                <li><a href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.fileName)</a></li>
            #end
        #end
    </ul>
#end
Elnaz Beirami October 25, 2017

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

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 20, 2017

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

Elnaz Beirami October 25, 2017

Thanks Nic for the info!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events