List labels by excluding other labels
Scenario
This recipe lists the labels from pages by excluding specified labels.
There is a situation where there are uncategorized labels that keep changing, while those that are categorized are not.
With the uncategorized labels being added more frequently, it is hard to find them all.
Hence, by excluding the label categories that are not changing, we can quickly get the ones that keep changing.
Result
Recipe
Apps | Reporting for Confluence Data Center |
|---|---|
Level | Intermediate |
Estimated time | 30 minutes |
Macros | Content Reporter, Expanding Reporter, Grouping Reporter, Report Body, Report Info, Report List, Text Filter, Text Sort |
Suppliers | Content Supplier, Expanded Supplier, Grouped Supplier, Label Supplier |
Storage format
You can copy and paste this code into the Confluence Source Editor:
<ac:structured-macro ac:macro-id="b71b7676-570a-44d7-88cf-c760649d6b4b" ac:name="report-list" ac:schema-version="1">
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="341ad03b-59c8-4433-8b15-25d422e125a6" ac:name="grouping-reporter" ac:schema-version="1">
<ac:parameter ac:name="as">myUniqueLabel</ac:parameter>
<ac:parameter ac:name="">expanded:myLabel</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="c3e01907-e549-4e9c-a819-abd1063f79c0" ac:name="expanding-reporter" ac:schema-version="1">
<ac:parameter ac:name="as">myLabel</ac:parameter>
<ac:parameter ac:name="">content:labels</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="beb68d0a-58db-4843-bee1-316b4f49a29f" ac:name="content-reporter" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="5c43a599-be4f-4668-b5c4-faeeb31e1459" ac:name="text-sort" ac:schema-version="1">
<ac:parameter ac:name="">label:title</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="8daafd43-50ef-45ba-b1c5-c2db123e6fbb" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="exclude">lab1|lab2|lab3</ac:parameter>
<ac:parameter ac:name="">grouped:myUniqueLabel</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="88f04b85-36c8-44c5-988b-14c243668321" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="exclude">demo|forum|q&a|training|panel|test</ac:parameter>
<ac:parameter ac:name="">grouped:myUniqueLabel</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br />
</p>
<p>
<br />
</p>
<ac:structured-macro ac:macro-id="35b944f9-b0e9-424c-8a86-cfdb0c3e3462" ac:name="report-body" ac:schema-version="1">
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="3695e283-f581-47e1-b42d-cb72adb69d43" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">grouped:myUniqueLabel</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
Macro structure
You can recreate the example in the editor view:
Steps
Add a Report List macro.
Within the Report List macro, create a Grouping Reporter with the following parameters:
Key:
expanded:myLabelAs:
myUniqueLabel
Within the Grouping Reporter macro, create an Expanding Reporter macro with the following parameters:
Key:
content:labelsAs:
myLabel
Within the Expanding Reporter macro, create a Content Reporter macro.
Within the Expanding Reporter macro, under the Content Reporter macro, create a Text Sort macro with the following parameters:
Key:
grouped:myUniqueLabelExclude:
<lab1>|<lab2>|<lab3>
If there is another label category that you want to exclude, add another Text Filter macro.
Within the Report List macro, under the Grouping Reporter macro, create a Report Body macro.
Within the Report Body macro, create a Report Info macro with the following parameters:
Key:
grouped:myUniqueLabelLink to item:
enabled