Hi,
I want to show a page label within the content the same way as it appears at the bottom of the page. I got to the stage where the labels are displayed following this suggestion by Steve (https://community.atlassian.com/t5/Answers-Developer-Questions/Is-there-a-way-to-place-a-list-of-the-page-s-labels-in-a/qaq-p/570841), but the rendered labels are simple text, not hyperlinks. My code is the following:
## Macro title: Page labels
## Macro has a body: N
## Body processing: No macro body
##
## Developed by: Steve Behnke
## @noparams
#set($currentPage = $pageManager.getPage($content.getId()))
#set($pageLabels = $currentPage.getLabels())
<span>
#foreach( $labelObject in $pageLabels )
<span class="aui-label">$labelObject.name</span>
#end
</span>
I guess the link element should go into the #foreach section, but I don't know how. Any help is much appreciated.
Many thanks,
Peter
Hi @Peter Baschan,
this should work:
#foreach( $labelObject in $pageLabels )
<span class="aui-label">
<a class="aui-label-split-main" href="/label/$space.key/$labelObject.name" rel="tag">$labelObject.name</a>
</span>
#end
Yes that should work. I built a similar structure for a macro recently.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You’re welcome, @Peter Baschan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
!! Thanks a lot to @Thomas Schlegel !!
I just introduced this nice little macro in our Confluence instance!
It will be very helpful!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.