How to view all attachments under one page tree? We require everyone to upload his attachments to his own project page under one page tree. I know the Space Attachment Macro to check the whole attachments in one space. But I just want to see the whole files of one page tree in a space. Does anyone know how to deal with it? Thanks!
Hi @jasper
Confluence does not offer a native macro that can directly list attachments from a specific page tree, as it only supports listing attachments for an entire space.
You can also explore some Marketplace Apps.
Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards
Hi @jasper if you need to list them from specific page give a try to my Page Information macro app
Regards, Roma (Wombats Corp)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Roma Bubyakin _Wombats Corp_ sorry that I cannot use the confluence cloud for we use data center version. I have no administration to try it. Maybe will be considered in the near future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@jasper it's actually much better, on the DC you can create a custom User Macro that will do whatever you need just from the admin panel.
Here is the template for you.
It is based on the JS and shows attachments as a clickable list.
As input, it uses Page ID or current as default.
## SERVER SYNTAX
## @param ID:title=Page ID|type=int|desc=Page ID to fetch attachments from|default=-1
## Determine the target page ID
#set ($pageID = $paramID)
#if ($pageID == -1)
#set ($pageID = $content.id) ## Default to current page if no ID is provided
#end
## Placeholder for the attachment list (will be populated by JavaScript)
<div id="attachment-list-$pageID">
<aui-spinner size="large"></aui-spinner>
</div>
<script>
(function() {
var pageID = "$pageID";
var container = document.getElementById("attachment-list-" + pageID);
var baseUrl = window.location.origin;
fetch(baseUrl + "/rest/api/content/" + pageID + "/child/attachment")
.then(response => response.json())
.then(data => {
if (data.results && data.results.length > 0) {
var listHtml = "<ul>";
data.results.forEach(attachment => {
var fileName = attachment.title;
var fileUrl = baseUrl + attachment._links.download;
listHtml += `<li><a href="${fileUrl}" target="_blank">${fileName}</a></li>`;
});
listHtml += "</ul>";
container.innerHTML = listHtml;
} else {
container.innerHTML = "<p><strong>No attachments found</strong> for the specified page.</p>";
}
})
.catch(error => {
console.error("Error fetching attachments:", error);
container.innerHTML = "<p style='color:red;'><strong>Error fetching attachments.</strong></p>";
});
})();
</script>
Preview example with one attachment:
The best part is that you can modify it in any way you wish!
P.S. If you need help with that, just let me know
Regards,
Roman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.