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
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,777 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