Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Macro extract number of links on a page

john_carmichael
Contributor
November 9, 2020

So from the communty posts i could put together a macro which counts the number of children under any given page (https://community.atlassian.com/t5/Confluence-questions/Macro-to-count-child-pages-of-specified-page/qaq-p/157546#link_1_9878d803e9bd1b):


#set($pageManager=$containerContext.getComponent('pageManager'))
#set($currentPage=$pageManager.getPage($space.key, $content.title))
#set($children=$currentPage.getChildren())
#set($count=$children.size())

$count

Is there a function that will allow me to return the number of internal links within a page?

eg:

#set($pageManager=$containerContext.getComponent('pageManager')) 
#set($currentPage=$pageManager.getPage($space.key, $content.title))
#set($linksCount=$currentPage.getLinksCount())

$linksCount

It would be expected the output here to be a number representing the hyperlinks on the current page, ideally with the option to restrict the count to either "internal" or "external"

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.7.3
TAGS
AUG Leaders

Atlassian Community Events