Displaying the headings of the child pages

Displaying the headings of the child pages

Scenario

This recipe will help you to create a report that lists the content of the child pages and displays the headings of those child pages. 

Result

Recipe

Apps

Reporting for Confluence Data Center

Level

Intermediate

Estimated time

15 minutes

Macros

Local Reporter, Report Column, Report Info, Report Table

Suppliers

Body Supplier, Content Supplier, Text Supplier

Storage format

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

<pre> <br /> </pre> <ac:structured-macro ac:macro-id="15466407-0adf-4de3-8a44-474ac9b50699" ac:name="report-table" ac:schema-version="1"> <ac:rich-text-body> <ac:structured-macro ac:macro-id="4e7f7db0-120f-4035-a19e-ca5896cdecc9" ac:name="local-reporter" ac:schema-version="1"> <ac:parameter ac:name="">page:children</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="f856f271-ce21-4e74-b05a-9b83fe0f9e3e" ac:name="text-sort" ac:schema-version="1"> <ac:parameter ac:name="">page:title</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <ac:structured-macro ac:macro-id="ea9ed1fc-979c-473e-b7d6-54c1690ad5b0" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Page Name</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="4393fdc7-4167-4c34-b4f7-99932f20ce15" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="link">true</ac:parameter> <ac:parameter ac:name="">page:title</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <ac:structured-macro ac:macro-id="b73dcec4-989c-4865-b70b-8170db84e225" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">All Headings</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="a2d04982-8411-4af7-9749-b159be78ff97" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="render">richtext</ac:parameter> <ac:parameter ac:name="">content:body&gt; body:text </ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <ac:structured-macro ac:macro-id="9f3ada09-3826-41f6-92f2-8bc4614a3ba0" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Heading H1</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="e848206c-11fa-4575-97e0-ef945e3a8558" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="link">true</ac:parameter> <ac:parameter ac:name="render">richtext</ac:parameter> <ac:parameter ac:name="">content:body&gt; body:text &gt; text:find "(&lt;h1&gt;)(.*?)(&lt;/h1&gt;)"&gt;collect "value"&gt;join with " &lt;br/&gt; "</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <ac:structured-macro ac:macro-id="233db359-b63c-4f4b-adfb-c9a659b60d57" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Heading H3</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="28de30d9-a4d5-44e0-a3a8-fc913feb5248" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="link">true</ac:parameter> <ac:parameter ac:name="render">richtext</ac:parameter> <ac:parameter ac:name="">content:body&gt; body:text &gt; text:find "(&lt;h3&gt;)(.*?)(&lt;/h3&gt;)"&gt;collect "value"&gt;join with " &lt;br/&gt; "</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p> <br /> </p> <p> <br /> </p> </ac:rich-text-body> </ac:structured-macro>

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a Report Table macro.

  2. Within the Report Table macro, create a Local Reporter macro with Key: page:children.

  3. Within the Local Reporter macro, create a Text Sort macro with Key: page:title.

  4. Within the Report Table macro, under the Local Reporter macro, create a Report Column macro with Title: Parent Title.

  5. Within the Report Column macro, create a Report Info macro with the following parameters:

    • Keypage:title

    • Link To Item: selected

  6. Under the Parent Title Report Column macro, create another Report Column macro with Title: Heading H1.

  7. Within the Heading H1 Report Column macro, create a Report Info macro with Key: content:body> body:text > text:find "(<h1>)(.*?)(</h1>)">collect "value">join with " <br/> ".
    With this part of the key text:find "(<h1>)(.*?)(</h1>), we will find and display only H1 headings. You can change it to H2, H3, etc