Listing Attachments from Current Page

Scenario

The Attachments macro could display a lot of information so, to simplify the amount of attachment data presented, follow this next recipe.

The recipe displays attachments from the current page into a neat simple table sorted by filename.

Result

Recipe

Apps

 

Reporting for Confluence Server

 

Apps

 

Reporting for Confluence Server

 

Level

Easy

Estimated time

15 minutes

Macros

Local Reporter, Report Column, Report Empty, Report Info, Report Table, Text Sort

Suppliers

Attachment Supplier, Content Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

<p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="1ad955f4-c886-48e2-bc53-e876dbc77959" ac:name="report-table" ac:schema-version="1"> <ac:rich-text-body> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="5508f08f-eacc-4dd1-a281-e88b49782f80" ac:name="local-reporter" ac:schema-version="1"> <ac:parameter ac:name="">content:attachments</ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="231c790e-3ca0-43da-8e21-ae4f55c15f37" ac:name="text-sort" ac:schema-version="1"> <ac:parameter ac:name="">attachment:title</ac:parameter> </ac:structured-macro> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="7d5db22d-8625-4d65-86de-69fbd3bd98d5" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">File Name</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="aa4e916f-e550-451e-8eb8-3aa94813563b" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="link">true</ac:parameter> <ac:parameter ac:name="">attachment:title</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="fb5e1bc2-dc65-4c7b-9f60-c3ef49bb6548" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Comment</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="9bfb3d07-5eb7-4ab9-99b0-41c1674807c5" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">attachment:comment</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="33ba4a9d-f26f-4b6c-8a4a-7e697ff8bb51" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Size</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="17f5df61-0221-47da-81d5-7600d6541d0a" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">attachment:nice file size</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="34dd7570-2c22-4108-b38b-3323c91aabc2" ac:name="report-empty" ac:schema-version="1"> <ac:rich-text-body> <p> <em>No files have been attached to this page.</em> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p>

 

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a Report Table macro.

  2. Inside that Report Table macro, create a Local Reporter macro.
    For the Key, specify content:attachments.

  3. Within the Local Reporter macro, create a Text Sort macro.
    For the Key, specify attachment:title.

  4. Create a Report Column macro within the Report Table macro, and add it below the Local Reporter macro.
    For the Title, specify "File Name".

  5. Within the Report Column macro, create a Report Info macro.
    For the Key, specify attachment:title.

  6. Within the Local Reporter, create another Report Column.
    For the Title, specify "Comment".

  7. Within the Report Column macro, create a Report Info macro.
    For the Key, specify attachment:comment.

  8. Within the Local Reporter, create another Report Column.
    For the Title, specify "Size".

  9. Within the Report Column macro, create a Report Info macro.
    For the Key, specify attachment:nice file size.

  10. Lastly, within the Local Reporter, create a Report Empty macro.