List contents with specific text or macros

List contents with specific text or macros

You may want to look for pages that use a specific macro that you want to amend.

This recipe generates a list of contents that contains a specific text or macro.

Result

Recipe

Apps

Reporting for Confluence Data Center

Level

Easy

Estimated time

10 minutes

Macros

Content Reporter, Report Column, Report Info, Report Table, Text Filter

Suppliers

Body Supplier, Collection Supplier, Content Supplier, Text Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

<p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="edaa8414-e427-4956-9004-a08781e545b4" ac:name="report-table" ac:schema-version="1"> <ac:rich-text-body> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="9d18386d-c24b-445e-9a20-9c7fd3c3f33e" ac:name="content-reporter" ac:schema-version="1"> <ac:parameter ac:name="space"> <ri:space ri:space-key="@all" /> </ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="8000b8b3-52e5-4534-a44b-c1c0676b54e8" ac:name="text-filter" ac:schema-version="1"> <ac:parameter ac:name="include">.*macroname.*</ac:parameter> <ac:parameter ac:name="required">true</ac:parameter> <ac:parameter ac:name="">content:body &gt; body:text</ac:parameter> </ac:structured-macro> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="3e113909-7cc1-41f6-a4c4-c2e061f89627" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Content</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="bddb85f2-1d9d-4d3d-9744-a8be052c67cb" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">content:title</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="4acf9106-81ea-41d9-9d1f-702b669a24dd" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Number of Matches</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="f3ce84f3-d040-417d-9c8f-4c203a6d9ef0" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">content:body &gt; body:text &gt; text:find macroname &gt; collection:size</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p>

 

Macro structure

You can recreate the example in the editor view:

 

 

Line-by-line explanation

Line

Description

Line

Description

1

The Report Table macro formats the report as a table.

2

The Content Reporter macro retrieves all contents in Confluence, with the Space parameter set to @all.

3

The Text Filter macro filters the contents retrieved from Content Reporter macro for the text or macro, with the following parameters:

  • Key: content:body > body:text uses the Content Supplier Supplier Keychains Body Supplier:

    • The first part content:body (Content Supplier) retrieves the body of each content from the Content Reporter macro.

    • The second part body:text (Body Supplier), chained using the > sign, supplies the storage text for the bodies.

  • Required: selected to filter out blank texts

  • Include: .*macroname.*, that is the name of the macro

4

Two Report Column macros create two table columns, with Title parameters set accordingly - Content and Number of Matches.

5

The Report Info macro within the Content Report Column macro displays the page title, setting the Key to content:title (using the Content Supplier).

6

The Report Info macro within the Number of Matches Report Column macro displays the number of matches with macroname for each content, with the Key set to content:body > body:text > text:find macroname > collection:size uses the Content Supplier Supplier Keychains Body Supplier Supplier Keychains Text Supplier Supplier Keychains Collection Supplier:

  • The first part content:body (Content Supplier) retrieves the body of each content from the Content Reporter macro.

  • The second part body:text (Body Supplier), chained using the > sign, supplies the storage text for the bodies.

  • The third part text:find macroname (Text Supplier), chained using the > sign, retrieves the collection of matches for macroname.

  • The fourth part collection:size (Collection Supplier), chained using the > sign, gets the number of items in the list.