Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

User macro: change format of $body

Rina Nir
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 27, 2015

(Confluence 5.7)

Trying to write the following user macro (not a plugin- just from the user interface):

The body of the macro expects a list of link to other pages, and the macro should just apply bullet formatting on them.

The body html, may look like:

<p>
<ac:link>
<ri:page ri:content-title="Management review"/>
</ac:link>
</p>
<p>
<ac:link>
<ri:page ri:content-title="Documents control for HistoScanning, including DMR, DHR, DHF and TF"/>
</ac:link>
</p>

 

I digged and experimented with the macro, but could not figure out the right strategy. Any hints or examples are welcome.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 27, 2015

I would do something like this ...

## @noparams
#set( $id = $action.dateFormatter.calendar.timeInMillis )

&lt;div id="links$id"&gt;$body&lt;/div&gt;
&lt;style type="text/css"&gt;
    #links$id {list-style-type: disc; margin-top: 10px 0 0 0; padding: 0 0 0 40px;}
    #links$id p {display: list-item; margin: 0; padding 0;}
&lt;/style&gt;
Rina Nir
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 27, 2015

Wow, I can confirm it does work! Thanks Davin. I would have never thought about such a solution. Now- I want to do even something more advanced. I want to put next to each page link, a certain metadata value from that page, something like this: <p> <ac:structured-macro ac:name="metadata-from"> <ac:parameter ac:name="1">Document number</ac:parameter> <ac:parameter ac:name="0">Management review</ac:parameter> </ac:structured-macro>  <ac:link> <ri:page ri:content-title="Management review"/> </ac:link> </p> So actually- make a simple link into a more sophitsticated metadata+title combination?

0 votes
Nelson Carranza May 27, 2015

Hi R Nir,

This will work. if the pages are in the same space. the body must be a comma-separate list of titles

## @noparams
#set($list = $body.split(','))
#foreach($link in $list)
&lt;p&gt;
&lt;ac:link&gt;
&lt;ri:page ri:content-title="$link"/&gt;
&lt;/ac:link&gt;
&lt;/p&gt;
#end

 

Regards

Nelson

Rina Nir
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 27, 2015

Thankyou for the quick response, it does the work. . Is there a way to achieve the same if the body is not a comma seperated list but the above structured html?

TAGS
AUG Leaders

Atlassian Community Events