Create a report that filters pages by a label specified in a Scaffolding field
Scenario
With this recipe, you can create a simple search engine to search for pages that have a specific label.
This recipe lets you insert the name of the label in a Scaffolding macro. This will generate a report with pages that contain that label.
Result
Recipe
Apps | Reporting for Confluence 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 (from the Scaffolding app) with the following parameters, for users to enter the label they want to report on.
Name:
Label AContent type:
TextRequired: selected
Outside the Text Data macro, create a Report Table macro with Injected: selected.
We recommend using the Maximum Results parameter to limit the number of results so that page performance will not be affected.
Within the Report Table macro, create a Content Reporter macro with the following parameters:
Types:
pageLabels:
+%data:Label A > text:lower case%
Within the Report Table macro, under the Content Reporter macro, create a Report Column macro with Title:
Page Title.Within the Page Title Report Column macro, create a Report Info macro with the following parameters:
Key:
content:titleLink To Item: selected
Under the Page Title Report Column macro, create another Report Column with Title:
Labels.Within the Labels Report Column macro, create a Report Info macro with the following parameters:
Key:
content:labelsLink To Item: selected
Under the Labels Report Column macro, create a Report Empty macro with the following text in the macro body:
No pages with the input labels in this space.Save the page.
To display the report results, you must click Edit Contents, enter a label to report on, and click Save.