Create a report that filters by label
Scenario
Using this recipe, you will create a simple search engine to search for pages that have a specific label.
To do this, insert the name of the label in the Scaffolding macro. This will generate a Report with pages that contain that label.
Result

Recipe
Apps | Reporting for Confluence Server & Data Center, Scaffolding |
---|---|
Level | Intermediate |
Estimated time | 15 minutes |
Macros | Content Filter, Report Column, Report Empty, Report Info, Report Table |
Suppliers | Content Supplier, Page Supplier, Scaffold Data Supplier |
Storage format
You can copy and paste this code into the Confluence Source Editor:
<ac:layout>
<ac:layout-section ac:type="single">
<ac:layout-cell>
<p class="auto-cursor-target">Please enter the labels below:</p>
<table class="wrapped relative-table" style="width: 43.1121%;">
<colgroup> <col style="width: 12.4378%;" /> <col style="width: 87.5253%;" /> </colgroup>
<tbody>
<tr>
<th>Label A</th>
<td>
<div class="content-wrapper">
<ac:structured-macro ac:macro-id="62493f2e-e051-4fe4-90cb-40893f9aa08a" ac:name="text-data" ac:schema-version="1">
<ac:parameter ac:name="name">Label A</ac:parameter>
<ac:parameter ac:name="type">line</ac:parameter>
<ac:parameter ac:name="content">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
</div>
</td>
</tr>
</tbody>
</table>
</ac:layout-cell>
</ac:layout-section>
<ac:layout-section ac:type="single">
<ac:layout-cell>
<ac:structured-macro ac:macro-id="4e949d60-d5cc-456a-8872-f546a3e16b48" ac:name="report-table" ac:schema-version="1">
<ac:parameter ac:name="maxResults">5</ac:parameter>
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="4c2c83d2-501e-476d-b1c1-0f05319fcf76" ac:name="content-reporter" ac:schema-version="1">
<ac:parameter ac:name="types">page</ac:parameter>
<ac:parameter ac:name="labels">+%data:Label A > text:lower case%</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="691553ac-d659-448c-b2a7-a62de5bf4040" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="title">Page Title</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="ce782509-554e-4581-beed-245ec91bbcf6" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">content:title</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="6691f986-405f-47db-97fe-336e0d0b1903" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Labels</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="5529c547-36c4-4d05-b855-7cd4282914fe" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">page:labels</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="e96e8582-1c37-4db7-8e55-e2971d4463a9" ac:name="report-empty" ac:schema-version="1">
<ac:rich-text-body>
<p>
<em>No pages with the input labels in this space.</em>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
</ac:layout-cell>
</ac:layout-section>
</ac:layout>
Macro structure
You can recreate the example in the editor view:

Steps
Create a Text Data macro for users to type in the label they would like to report on.
Set the parameters as below:Name: Label A
Content type: TextRequired: Yes
Create a Report Table macro.
Set Injected parameter to True.We recommend limiting the number of results so that page performance will not be affected. This can be done in the "maxResults" field.
Within Report Table macro, create a Content Reporter macro and set the following parameters:
Type: pages
Labels:+%data:Label A > text:lower case%
Within Report Table macro, under Content Reporter macro, create 2 Report Column macros.
Set the first Report Column macro's Title to "Page Title" and add a Report Info macro within it.
Set the Report Info macro's Key to "content:title
". Tick Link To Item.Set the second Report Column macro's Title to "Labels" and add a Report Info macro within it.
Set the Report Info macro's Key to "page:labels
".Tick Link To Item.Add a Report Empty. Write a message that users will see when there are no pages with the label.
Save the changes.
Now, you can click on Edit Contents to type a Label to report on.
The results will be displayed only after you have typed the label and clicked on Save.