Is there any way for the attachments macro to pull attachments from more than one page?
Asked by Daniel Pasacrita:

Basically just the title. I'd like to make the attachments macro pull attachments from two different pages as the same list of attachments. I tried commas and semicolons to list two different pages, but it wouldn't work. Any way to do this?


Answers:
author: Davin Studer
body: You could create your own with a user macro. Here is one that I created that mimics the page attachments maco somewhat. I did this because the bundlesd one had (not sure if it still does) massive performance issues with pages that have lots of attachments. It would try and render a thumbnail of each attachment and if the page has hundreds it would bring the server to its knees. So, I created this one that just displays a list of them in a table. You could edit it to work with multiple pages.

```
## Macro title: tvc_attachments## Macro has a body: N## Developed by: Davin Studer## Date created: 08/07/2013## This macro will allow you to display a list of the page attachments without the preview functionality included in the built in attachments macro.## @param Label:title=Attachment Label|type=string|required=false|desc=Enter a label to filter the attachments by.## @param Page:title=Page Title|type=confluence-content|required=false|desc=If not specified, the current page is used.#if( $paramPage &amp;&amp; $paramPage != "" )    ##########################    ## Get the page manager ##    ##########################    #set( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )    #set( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )    #set( $containerManager=$getInstanceMethod.invoke(null,null) )    #set( $containerContext=$containerManager.containerContext )    #set( $pageManager=$containerContext.getComponent('pageManager') )        ##########################    ## Find the page        ##    ##########################    #set( $parts = $paramPage.split(":") )    #set( $i = 0 )    #set ( $len = 0 )    #set( $key = "" )    #set( $name = "" )    ##Having trouble finding out the length/size of $parts ... brute force it    #foreach ( $part in $parts )        #set ( $len = $len + 1 )    #end        #if ( $len == 1 )        #set ( $key = $content.spaceKey )        #set ( $name = $paramPage )    #else        #foreach ( $part in $parts )            #if ( $i == 0 )              #set ( $key = $part )              #set ( $i = $i + 1 )           #else              #set ( $name = $part )           #end        #end    #end    #set ( $tempcontent = "" )    #if ( $pageManager )        #set ( $tempcontent = $pageManager.getPage($key, $name) )    #end    #if ( $tempcontent &amp;&amp; $tempcontent != "" )        #set ( $content = $tempcontent )    #else        The page "$paramPage" was not found in this space.        #set ( $content = "" )    #end#end#set ( $attachments = $content.getLatestVersionsOfAttachments() )&lt;table class="tvc_attachments"&gt;    &lt;tr&gt;        &lt;th class="tvc_attachments_filename_column"&gt;File&lt;/th&gt;        &lt;th class="tvc_attachments_modified_column"&gt;Modified&lt;/th&gt;    &lt;/tr&gt;    #foreach( $attachment in $attachments )        #if( $paramLabel &amp;&amp; $paramLabel != "" )            #foreach( $lab in $attachment.getLabels())                #if( $lab == $paramLabel )    &lt;tr&gt;        &lt;td class="tvc_attachments_filename_column"&gt;            &lt;a class="tvc_attachments_$attachment.getFileExtension()" href="$attachment.getDownloadPath()" target="_blank"&gt;$attachment.getTitle()&lt;/a&gt;        &lt;/td&gt;        &lt;td class="tvc_attachments_modified_column"&gt;            $action.dateFormatter.format($attachment.getLastModificationDate()) by  #usernameLink($attachment.getLastModifierName())        &lt;/td&gt;    &lt;/tr&gt;                #end            #end        #else    &lt;tr&gt;        &lt;td class="tvc_attachments_filename_column"&gt;            &lt;a class="tvc_attachments_$attachment.getFileExtension()" href="$attachment.getDownloadPath()" target="_blank"&gt;$attachment.getTitle()&lt;/a&gt;        &lt;/td&gt;        &lt;td class="tvc_attachments_modified_column"&gt;            $action.dateFormatter.format($attachment.getLastModificationDate()) by #usernameLink($attachment.getLastModifierName())        &lt;/td&gt;    &lt;/tr&gt;        #end    #end&lt;/table&gt;
```


author: Eirik Midttun
body: For the **Attachments** macro the [documentation](https://confluence.atlassian.com/display/DOC/Attachments+Macro "documentation") says: "Displays a list of attachments on a given page." There is another macro called **Space Attachements**which gives the attachement of the whole space, but that may give you too much. You can filter on file extension though.


Tags: confluence-administration