Content by label with external variables or metadata

Hello,

I would like to know if it's possible to use "Content by label" with a variable like picture below instead the name of the label (label1)

image2015-9-18 14:22:18.png

I tried to modify the macro "Content by label" like this:

## This is an example macro
## @param Name:title=Author|type=string|required=false|desc=Author name
## @param Title:title=Title|type=string|required=true|desc=Title of labelled page
## @param ShowLabel:title=Show label|type=string|required=true|desc=Show label or not (true, false)
## @param Label:title=Label|type=string|required=true|desc=Label name
#set ( $spaceKey = $space.getKey() )
<ac:structured-macro ac:name="contentbylabel">
<ac:parameter ac:name="spaces"/>
<ac:parameter ac:name="author">$paramName</ac:parameter>
<ac:parameter ac:name="title">$paramTitle</ac:parameter>
<ac:parameter ac:name="showLabels">$paramShowLabel</ac:parameter>
<ac:parameter ac:name="reverse">true</ac:parameter>
<ac:parameter ac:name="sort">creation</ac:parameter>
<ac:parameter ac:name="max">10</ac:parameter>
<ac:parameter ac:name="excerpt">true</ac:parameter>
<ac:parameter ac:name="labels">$paramVar1</ac:parameter>
<ac:parameter ac:name="showSpace">false</ac:parameter>
<ac:parameter ac:name="type">page</ac:parameter>
<ac:parameter ac:name="operator">AND</ac:parameter>
</ac:structured-macro>

But I can't to read the content of the page. 

I tried this : $content.MyVariable instead $paramVar1...

Any ideas?

Thank you!

 

1 answer

I'm not sure how you going to provide your variable label when opening the page.

But if you have Bob Swift Run plugin installed it is possible to wrap Content By Label inside Run plugin. Then you can add label value as a field input in Run plugin which is then passed to Content By Label as a variable.

<ac:structured-macro ac:name="run">
<ac:parameter ac:name="replace">label:label1:Specify Label</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p><ac:structured-macro ac:name="contentbylabel">
<ac:parameter ac:name="labels">$label</ac:parameter>
</ac:structured-macro></p>
</ac:rich-text-body>
</ac:structured-macro>

 

I don't have this plugin... It's not possible to read content of the page? If yes, I will read the content of the page and I will call macro "ContentByLabel" after... Something like this : $content.myvar instead $label...

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

903 views 23 12
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