The macro processes user-defined parameters to construct a CQL query for searching Confluence content.
#set($labelParam = $StringUtils.lowerCase($parameters.label))
#set($excludeLabelParam = "")
#if($parameters.excludeLabel)
#set($excludeLabelParam = $StringUtils.lowerCase($parameters.excludeLabel))
#end
#set($contentType = $parameters.contentType)
#set($specificSearch = $parameters.specificSearch)
#set($spaceKey = $parameters.targetSpaceKey)
#set($ancestorId = $parameters.ancestorID)
## Split labels and excludeLabels by commas into lists and trim each label to avoid spaces
#set($labels = [])
#foreach($label in $StringUtils.split($labelParam, ","))
#set($discard = $labels.add($StringUtils.trim($label)))
#end
#set($excludeLabels = [])
#foreach($excludeLabel in $StringUtils.split($excludeLabelParam, ","))
#set($discard = $excludeLabels.add($StringUtils.trim($excludeLabel)))
#end
## Initialize CQL base query with content type
#if($contentType)
#set($cqlQuery = "type=$contentType")
#else
#set($cqlQuery = "type in (page, blogpost, attachment)")
#end
## Add spaceKey condition if provided
#if($spaceKey)
#set($cqlQuery = "$cqlQuery AND space='$spaceKey'")
#end
#if($ancestorId)
#set($cqlQuery = "$cqlQuery AND ancestor=$ancestorId")
#end
## Build label conditions based on specificSearch parameter
#if($labels)
#if($specificSearch)
## Specific search: join labels with AND condition
#set($labelCondition = "label='" + $StringUtils.join($labels, "' AND label='") + "'")
#set($cqlQuery = "$cqlQuery AND ($labelCondition)")
#else
## Default search: join labels with OR condition
#set($labelCondition = "label='" + $StringUtils.join($labels, "' OR label='") + "'")
#set($cqlQuery = "$cqlQuery AND ($labelCondition)")
#end
#end
## Exclude labels if excludeLabels parameter is provided
#if($excludeLabels)
#set($excludeCondition = "label='" + $StringUtils.join($excludeLabels, "' AND NOT label='") + "'")
#set($cqlQuery = "$cqlQuery AND NOT ($excludeCondition)")
#end
## Execute CQL search request using constructed cqlQuery
#set($response = $ConfluenceManager.get("/wiki/rest/api/content/search?cql=$cqlQuery&expand=metadata.labels"))
## Render search results or message if no results found
#if($response.results && $response.results.size() > 0)
<ul>
#foreach($result in $response.results)
<li style="list-style-type: circle;"> <a href="$response._links.base$result._links.webui" target="_blank">$result.title</a>
<span class="aui-lozenge aui-lozenge-subtle aui-lozenge-success">
#foreach($label in $result.metadata.labels.results)
$label.name
#if($foreach.hasNext) &
#end
#end
</span>
</li>
#end
</ul>
#else
<p>
No results found for the specified criteria.
</p>
#endGenerate a list of all content created by the current user by default, or by a specified user, across your Confluence site
Show confetti bursts and a motivational message upon saving an edited page
Add a configurable floating panel to a Confluence page
Display a custom list of recently updated content
Display the top comments from a selected Confluence page, or from the current page by default
Generate an alphabetical list of labels from all spaces, linking each label to its corresponding content pages
Display the creation date of the current Confluence page
Parse a table containing cost and currency columns, convert each row's value into a selected target currency, and append a footer row showing the total amount. Useful for tracking multi-currency expenses and reporting totals in a unified currency.
Improve default Confluence tables with sorting, filtering, pagination, and CSV export features
Retrieve and display labels from a specified space