Recipe for using Reporting Plugin to combine tables from child pages

Ryan Moore May 4, 2012

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

0 votes
Ryan Moore August 6, 2013

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

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

0 votes
Ryan Moore August 6, 2013

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?

0 votes
TomTom August 6, 2013

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

0 votes
Kenneth Snyder August 19, 2012

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?

0 votes
Kenneth Snyder August 19, 2012

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events