Skip to content

Instantly share code, notes, and snippets.

@AlexandrYZ
Created August 12, 2020 10:50
Show Gist options
  • Save AlexandrYZ/677c40924f2062ddd9c43b7e4d4c426d to your computer and use it in GitHub Desktop.
Save AlexandrYZ/677c40924f2062ddd9c43b7e4d4c426d to your computer and use it in GitHub Desktop.
Confluence incoming links
## Macro title: incoming links - selected space
## Source - https://community.atlassian.com/t5/Answers-Developer-Questions/Get-incoming-links-with-in-a-user-macro/qaq-p/538128
## @param Space:title=Space|type=spacekey
#set($incLinks = $action.getIncomingLinks())
#if($incLinks && $incLinks.size() > 0)
<ac:structured-macro ac:macro-id="180b25d1-981f-410d-8fc7-b979b17f8ca2" ac:name="panel" ac:schema-version="1">
<ac:parameter ac:name="title">Links to this page from $paramSpace space</ac:parameter>
<ac:rich-text-body>
<p><ul>
#foreach ($incLink in $incLinks)
#if(!($incLink.getSourceContent().isDeleted()) && $incLink.getSourceContent().getSpace().getKey()==$paramSpace)
<li>[<a href="$generalUtil.htmlEncode("${req.contextPath}$incLink.getSourceContent().getSpace().getBlogTabUrlPath()")"> ($incLink.getSourceContent().getSpace().getName())</a>]<a href="$generalUtil.htmlEncode("${req.contextPath}$incLink.getSourceContent().getUrlPath()")">$incLink.getSourceContent().getTitle()</a></li>
#end
#end
</ul></p>
</ac:rich-text-body>
</ac:structured-macro>
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment