Stand with Ukraine 🇺🇦

Aggregated pages attributes — Confluence Cloud Macro

confluence-content

This Confluence user macro fetches and displays a table of page attributes based on a CQL query, including page title, author, last updated date, and status. It uses REST API calls to retrieve metadata and applies color-coded status indicators for better visibility.

Try for free

User Parameters

Search Query

CQL query, for instance: space = IDEAS or label = idea

Template

#set( $url = "/wiki/rest/api/content/search?cql=type=page and $parameters.query&limit=100&expand=version,history,space")
#set( $pages = $ConfluenceManager.get($url).results )

## Color mapping between statuses and Storage format
#set( $colors = {
    "#ffc400": "Yellow",
    "#2684ff": "Blue",
    "#57d9a3": "Green",
    "#8777d9": "Purple",
    "#ff7452": "Red"} )

<table>
  <thead>
    <tr>
      <th>Page</th>
      <th>Author</th>
      <th>Updated</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody
  
  #foreach ( $p in $pages )
    
    ## Get status of the page. Name and color
    #set($state = $ConfluenceManager.get("/wiki/rest/api/content/$p.id/state").contentState)
    #if($state)
      #if($state.name == "Verified")
        #set($sName = "✅  Verified")      
        #set($sColor = "")
      #else
        #set($sName = $state.name)
        #set($sColor = $colors.get($state.color))
      #end
    #end
    
    <tr>
      ## page
      <td>
        <ac:link>
          <ri:page ri:space-key="${p.space.key}" ri:content-title="${p.title}"/>
        <.ac:link>
      </td>
      ## author
      <td>
        <ac:link>
          <ri:user ri:userkey="${p.history.createdBy.accountId}"/>
        </ac:link>
      </td>
      ## updated date
      <td>$p.version.friendlyWhen</td>
      ## status
      <td>
        #if($state)
          <ac:structured-macro ac:name="status">
	          <ac:parameter ac:name="title">$sName</ac:parameter>
	          <ac:parameter ac:name="colour">$sColor</ac:parameter>
          </ac:structured-macro>
        #end
      </td>
    </tr>
  #end
  
  </tbody>
</table>