Recipe for using Reporting Plugin to combine tables from child pages

I've seen recipes that leverage the Scaffolding plugin to combine tables from child pages onto a parent page with a {report-table} . I'd like to share a way to accomplish something similar without using the Scaffolding plugin.

{report-table} 
{expanding-reporter:content:body > text:find ([^\\\\u007c]+)\\\\u007c([^\\\\u007c]+)\\\\u007c([^\\\\u007c]+)\\\\u007c([^\\\\u007c]+)\\\\u007c([^\\\\u007c]+)\\\\u007c([^\\\\u007c]+)\\\\u007c[\\\\r\\\\n](\\?\\=[\\\\s\\\\S]*Next.Section)|as=foo} 
{local-reporter:content:children} 
{local-reporter} 
{expanding-reporter} 
{report-column:title=First Column|width=10em}{report-info:expanded:foo > match:group 1|render=wiki}{report-column} 
{report-column:title=Second Column|width=10em}{report-info:expanded:foo > match:group 2|render=wiki}{report-column} 
{report-column:title=Third Column|width=10em}{report-info:expanded:foo > match:group 3|render=wiki}{report-column} 
{report-column:title=Fourth Column|width=10em}{report-info:expanded:foo > match:group 4|render=wiki}{report-column} 
{report-column:title=Sixth Colum|width=10em}{report-info:expanded:foo > match:group 5|render=wiki}{report-column} 
{report-column:title=Seventh Column|width=10em}{report-info:expanded:foo > match:group 6|render=wiki}{report-column} 
{report-column:title=Eight Column|width=10em}{report-info:expanded:item > content:title > text:match (Report - YYYYMMDD - )(.*) > match:group 2}{report-column} 
{report-table}

Some notes about this:

  • \\\\u007c is how one puts a pipe '|' in the regex. One has to use the hex value and then triply escape it. Confluence tables use a lot of pipes, so this part is important.
  • The regex is basically looking for lines with pipes in them and pulling out strings between the pipes into regex groups.
  • The expanding reporter leverages 'text:find' to create the return list that this reporter requires.
  • The parens in the regex pass regex groups down through the {report-info} which can then be accessed with the 'match:group'. Recall that the expanding reporter is a wrapper for the report-info.
  • 'render=wiki' will keep unwanted bits in the markup from appearing.
  • This regex uses a positive lookahead to make sure it's pulling from the correct table. A negative lookahead may also be used in case the child page has many tables.

If folks have any interest or questions, I can post more of an explanation. But I think for most folks familiar with the Reporting plugin will find this helpful.

5 answers

Hello, I am new to Confluence. But I need advice and if what you proprose above can help me.

I am using the “children” macro on my pages. I would like to combine the output of multiple children pages, such as:

{children:page=Service Coordination\|depth=1\|style=h4}

{children:page=Financials\|depth=1\|style=h4}

{children:page=Asset Management\|depth=1\|style=h4}

But I want to sort them as ALL children pages, instead of as separate sections.

I am looking to merge the output and sort data.

Is this possible?

I am using the “children” macro on my pages.

I would like to combine the output of multiple children pages, such as:

{children:page=Service Coordination\|depth=1\|style=h4}

{children:page=Financials\|depth=1\|style=h4}

{children:page=Asset Management\|depth=1\|style=h4}

But I want to sort them as ALL children pages, instead of as separate sections.

I am looking to merge the output and sort data.

Is this possible?

Hi Ryan,

thanks for sharing this approach!

Unfortunately, I can't get it working. I guess the issue I have is related to some update of the reporting plugin. I get the message, that I need to provide the key to expand on.

May you be able (in a free minute) to post two example tables and the report-on mark-up for combining those two tables?
I would also need to run this report on all pages having specific labels across all spaces. Should I use the content-reporter with the scope @global instead of the local-reporter in order to achieve this?

Thanks for your help & Cheers,
Tom

There's more than a few problem with the code I posted due to upgrade incompatabilities.

For starters, one now has to be explicit with suppliers:

"expanding-reporter:content:body > text:find" will no longer work. It has to be:

"expanding-reporter:content:body > body:text > text:find"

It's no longer possible to "shortcut" the supplier chain. I think this might be part of your problem Tom.

Additionally, the regex no longer works because the underlying structure is XHTML instead of wiki markup.

I'll try and post a new "fixed" example later.

In regards to your other question, wow, I'm not sure. You would have to somehow include all children in a space and then apply a fliter on the label?

Here's the new supplier chain in the expanding-reporter:

content:body > body:text > text:find "<tr><td.*?>(.*?)</td><td.*?>(.*?)</td></tr>"

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,891 views 25 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you