This is the documentation for an older version of Scroll Viewport. Here you can view the most up-to-date version of the Scroll Viewport documentation.

Customizing the Attachments Macro in a Viewport

Scroll Viewport comes with a special Viewport-aware replacement of the Confluence Attachments macro, that can be used to individually change the look of the attachments list.

Default Output of the Attachments Macro in Viewport

When a page is rendered in a viewport, Scroll Viewport will automatically replace the Confluence Attachments macro with the Viewport-aware Attachments macro. This means, users can (and should) use the Confluence Attachments macro. By default Scroll Viewport uses the following Velocity file to output the Attachments list:

#* @vtlvariable name="attachment" type="com.atlassian.confluence.pages.Attachment" *#
#* @vtlvariable name="dateFormat" type="java.text.SimpleDateFormat" *#
<table class="confluenceTable scroll-attachment-table">
    <thead>
    <tr>
        <th class="confluenceTh">$i18n.getText("heading.name")</th>
        <th class="confluenceTh">$i18n.getText("heading.version.number")</th>
        <th class="confluenceTh">$i18n.getText("heading.version.date")</th>
    </tr>
    </thead>
    <tbody>
        #foreach($attachment in $attachments)
        <tr>
            <td class="confluenceTd"><a href="${request.contextPath}${attachment.downloadPath}">$attachment.fileName</a></td>
            <td class="confluenceTd">$attachment.version</td>
            <td class="confluenceTd">
                #if($attachment.lastModificationDate)
                    $dateFormat.format($attachment.lastModificationDate)
                #else
                    $dateFormat.format($attachment.creationDate)
                #end
            </td>
        </tr>
        #end
    </tbody>
</table>

Customizing the Output of the Attachments Macro

Theme developers can override the default template of attachment macros, to change what information about the attachments is outputted and how it is rendered..

To customize the output of the attachments macro, you can override the default template as follows:

  1. Create a page overrides/attachments.vm in your theme and use the default template (above) and modify it.

    Use the JavaDoc for com.atlassian.confluence.pages.Attachment to see what additional information is available to be referenced. 

  2. Where you output the page contents, add that file to the overrides list like this:

    $page.renderContent("layouts/layout12.vm", {
        "sp-attachments" : "overrides/attachments.vm"
    })

Additional Resources