Extract values from page titles using Reporting Text Supplier

Scenario

This recipe will help you to extract certain values from page titles and then show them in different columns using the Text Supplier macro.

In this example, we use the Page Supplier and Text Supplier macros to extract a number from page titles.

Result

Recipe

Apps

Reporting for Confluence Server & Data Center, Linking for Confluence Server

Apps

Reporting for Confluence Server & Data Center, Linking for Confluence Server

Level

Easy

Estimated time

10 minutes

Macros

Local Reporter, Report Column, Report Info, Report Table

Suppliers

Page Supplier, Text Supplier

Storage format

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

<p>Create a Child Page: <ac:structured-macro ac:macro-id="164092d7-53b7-498c-986f-16b720d77dea" ac:name="add-page" ac:schema-version="1"> <ac:parameter ac:name="name">Child Page %child-counter:next &gt; number:000%</ac:parameter> <ac:parameter ac:name="linkText">Create Child Page</ac:parameter> </ac:structured-macro> </p> <hr /> <p>List of Children Pages:</p> <ac:structured-macro ac:macro-id="ac02fa1e-1f5c-48ed-a2de-cb2cb25f3520" ac:name="report-table" ac:schema-version="1"> <ac:rich-text-body> <ac:structured-macro ac:macro-id="77342fca-1f4e-4496-b49c-a07c622b1dd7" 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="7ae77974-2eff-4c97-8cd3-ac9634aad176" 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="1c053104-056e-444c-8bb6-f8eaac8a51e7" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Page Title</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="ea25a2f0-ffe4-4a47-8085-f7f3ede8bf93" 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="22b23480-5cbe-4441-907c-fe1fc6a00bae" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Page Number (Extracted from Page Title)</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="f12c0810-c0ce-4495-84c0-d29b140a80bb" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">page:title&gt;text:last 3&gt;text:as number</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

  1. Create a page and child page titles that have a format of "Child Page 000".

  2. Add a Report Table macro and within add a Local Reporter macro.

  3. Set the Local Reporter macro's Key parameter to page:children.

  4. Inside the Local Reporter macro, add a Text Sort macro and set the Key to page:title.

  5. Below the Local Reporter macro, add two Report Column macros.

  6. Set the first Report Column macro's Title to "Page Title" and add a Report Info macro within it.

  7. Set the Report Info macro's Key to page:title and Link to item to True.

  8. Set the second Report Column macro's Title to "Page Number" and add a Report Info macro within it.
    Set the Report Info macro's Key to page:title>text:last 3>text:as number.

Optionally, you can use a Add Page macro from Linking for Confluence to create the Children pages with a running number.

Insert an Add Page macro to the top of the page and and set the following:

  • Name to Child Page %child-counter:next > number:000%

  • Link Text to Create a Child Page