How to get all the page details such as PageName,CreationDate and Last modified date using usermacro

Mrunal Kumar Lokku May 10, 2023

Need to display the page details in table format using user macro in confluence

2 answers

0 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

The general doc is here: https://community.atlassian.com/t5/Confluence-questions/How-to-get-all-the-page-details-such-as-PageName-CreationDate/qaq-p/2356767

Note that when you work with user macro context objects, those are instances of the corresponding internal Java classes. Therefore, if you want to work with page objects, 

Resources:

  1. Context objects in general: https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity/
  2. Javadoc of the AbstractPage class: https://docs.atlassian.com/ConfluenceServer/javadoc/8.2.2/com/atlassian/confluence/pages/AbstractPage.html
  3. Because AbstractPage is inherited from ContentEntityObject, you should look for the base properties here: https://docs.atlassian.com/ConfluenceServer/javadoc/8.2.2/com/atlassian/confluence/core/ContentEntityObject.html

All in all, the page name and creation date can be accessed like this assuming that the object is "$page":

${page.displayTitle}
${page.creationDate}
...

 

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023
Mrunal Kumar Lokku May 11, 2023

Hi Alex, 

I tried the following macro but this macro is page specific. So, can you please help me for modifying this macro in such a way that I can get all the page details?

## @Param Page:title=Page|type=confluence-content|required=true|desc=Choose Page to get the Information for
#set ( $colonIndex = $paramPage.indexOf(":") )
#if ( $colonIndex == -1 )
#set ( $spaceKey = $space.key )
#set ( $pageName = $paramPage )
#else
#set ( $spaceKey = $paramPage.substring(0, $colonIndex) )
#set ( $pageNameIndex = $colonIndex + 1 )
#set ( $pageName = $paramPage.substring($pageNameIndex) )
#end
#set ( $requestedPage = $pageManager.getPage($spaceKey, $pageName) )
<table>
<tr>
<td>Page Name</td>
<td>Page Creator Name </td>
<td>Last Modified Date</td>
<td>Last Modifier </td>
</tr>
<tr>
<td>$requestedPage.getTitle()
<td>$requestedPage.getCreatorName()</td>
<td>$action.dateFormatter.formatDateTime($requestedPage.lastModificationDate)</td>
<td>$requestedPage.getLastModifierName()</td>
</tr>
</table>

 

Thanks,

Mrunal

Mrunal Kumar Lokku May 15, 2023

Hi,

Can you please suggest the changes in the above macro for displaying all the pages details in confluence.

Thanks,

Mrunal

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events