It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

User Macro to add version and date to all links inside

Greetings!

Context: my final goal is to have a big tree of company documentation (100+ documents divided onto several categories + subcategories +subsubcategories). I am using combination of horizontal and vertical menus for it.

I've created a user macro, which renders selected page as a hyperlink and adds version + last modification date below the link (code posted below).

However I feel that supporting it in a blanket-like final page editing space will be very hard, since browser doesn't even see text in macro placeholder (so, I wouldn't be able to find a necessary link/page quickly and have to scroll down to it by my own).

Is this hard to convert it into user macro with a body, which parses all links inserted in it and adds version + modification date?

Thanks.

## Macro title: LINK
## Macro has a body: No
## Body processing: No Macro Body
## Output: Selected output option
##
## Developed by: Vladimir + Stackoverflow
## Date created: 23 Apr 2020
## Created by: Vladimir

## @param Page:title=Page|option-showTitleInPlaceholder=true|type=confluence-content|desc=Target page
#if ($paramPage.contains(':'))
#set ( $strArray = [] )
#foreach($str in $paramPage.split(':'))
#set($dummy = $strArray.add($str)) ## Assign returnval to avoid printing 'true'.
#end
#set($spacekey = $strArray.get(0).trim())
#set($pagetitle = $strArray.get(1).trim())
#else
#set($spacekey = $content.getSpaceKey()) ## Current spacekey
#set($pagetitle = $paramPage.trim())
#end
#set ($urlPath = $pageManager.getPage($spacekey, $pagetitle).getUrlPath())
#set ( $requestedPage = $pageManager.getPage($spacekey, $pagetitle) )

<ac:link>
<ri:page ri:content-title="$pagetitle" ri:space-key="$spacekey"/>
<ac:plain-text-link-body><![CDATA[$pagetitle]]></ac:plain-text-link-body>
</ac:link>
<br/>
<p style="font-size:11px; margin-top: -3px;">v. $requestedPage.version ($action.dateFormatter.formatDateTime($requestedPage.lastModificationDate))</p>

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Enhancements to the Confluence Mobile App

  Hey Community! I’m Stephanie Zhang, a Product Manager along with @Wei on the Confluence mobile app. Our team has been hard at work to deliver helpful enhancements to the Confluen...

157 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you