Displaying the headings of the children pages
Scenario
This recipe will help you to create a report that lists down the content of the children’s pages and displays the headings of those children’s pages.
Result
Recipe
Apps | Reporting for Confluence Server & 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> 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> body:text > text:find "(<h1>)(.*?)(</h1>)">collect "value">join with " <br/> "</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> body:text > text:find "(<h3>)(.*?)(</h3>)">collect "value">join with " <br/> "</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
Create a Report Table macro.
Within the Report Table macro, create a Local Reporter macro.
Set the Key parameter to page:children.Within the Local Reporter macro, create a Text Sort macro.
Set the Key parameter to page:title.Within the Report Table macro and under the Local Reporter macro, create a Report Column macro.
Set the Title parameter to Parent Title.Within the Report Column macro, create a Report Info macro.
Set the Key parameter to page:title.
Check the Link to Item parameter.Back within the Report Table macro, create another Report Column macro.
Set the Title parameter to Heading H1.Within the Report Column macro, create a Report Info macro.
Set the Key parameter to 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, feel free to change it to H2, H3, etc.