It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Only current space in the Content Report Table macro

Kitty de Ruijter Jan 20, 2017

This question is in reference to Atlassian Documentation: Content Report Table Macro

Hi,

In the Content Report Table macro I have to fill in a space key to which space the macro should refer to. The default is set on all spaces, but I want it to look only at the current space. As I am also using this macro in a blueprint, I don't want to manually update the space key everytime. Anyone has any idea's?

 

Thanks in advance.

3 answers

1 accepted

0 votes
Answer accepted
Davin Studer Community Leader Jan 20, 2017

You could create a user macro to wrap the built-in macro that has all the same params except the space and will auto fill the space for you. I have included one below.

Current Space Content Report Table

Macro Name:
current_space_content_report_table 

Macro Title:
Current Space Content Report Table 

Description:
Provides a content report for the current space in table format, based on labels. 

Macro Body Processing:
No macro body 

Template:

## Developed by: Davin Studer
## Date created: 01/20/2017
## @param Labels:title=Label(s)|type=string|required=true|desc=Enter one or more labels to report on.
## @param Comments:title=Show Comments count|type=boolean|desc=Add the column that displays numbers of comments
## @param Likes:title=Show Likes count|type=boolean|desc=Add the column that displays numbers of likes
## @param Max:title=Maximum Number of Pages|type=string|default=20|desc=

#if ($paramComments && $paramComments == true)
    #set ($comments = "true")
#else
    #set ($comments = "false")
#end
#if ($paramLikes && $paramLikes == true)
    #set ($likes = "true")
#else
    #set ($likes = "false")
#end
<ac:structured-macro ac:macro-id="d28458e5-6177-43aa-a298-75d9539c8d84" ac:name="content-report-table" ac:schema-version="1">
    <ac:parameter ac:name="showLikesCount">$likes</ac:parameter>
    <ac:parameter ac:name="maxResults">$!paramMax</ac:parameter>
    <ac:parameter ac:name="showCommentsCount">$comments</ac:parameter>
    <ac:parameter ac:name="spaces">
        <ri:space ri:space-key="$space.key"/>
    </ac:parameter>
    <ac:parameter ac:name="labels">$!paramLabels</ac:parameter>
</ac:structured-macro>
Kitty de Ruijter Jan 23, 2017

Yes this did the trick! Thanks for the help smile

Davin Studer Community Leader Jan 23, 2017

No problem.

0 votes
Rob Woodgate Jan 20, 2017

Hi Kitty,

In some macros you can specify "current space", but for reasons known only to Atlassian you can't use that in the Content Report Table.  It doesn't even have the type-ahead so you have to know the exact name or key of every space you want to pull data from.  It's very odd and as far as I know there is no workaround for this - if you want "current space" you'll have to manually change it to the space name every time.

An alternative that does what you need is the Content By Label macro.  It's not a neat table, but you could set it up with the label(s) you want and set an additional In space filter to "Current space", drop it in your template and you're all done.

0 votes

If you have access to change the code in the blueprint, you may workaround the problem by setting a variable in the environment.

blueprintContext.put("spaceKeyElement",
        "<ri:space ri:space-key=\"" + spaceKey + "\" />");

In the blueprint you access this variable like this:

<ac:structured-macro ac:name="...">
  ...
  <ac:parameter ac:name="spaceKey"><at:var at:name="spaceKeyElement" 
                                           at:rawxhtml="true"/></ac:parameter>
</ac:structured-macro>

This is quite a hack, but it works in our use cases. Hopefully this also works with the Content Report Table (I have not tested it).

This issue is related: https://answers.atlassian.com/questions/318493

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

945 views 0 19
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you