Background
Sometimes, there is a requirement to generate the countdown based on the output from other macros
-
ConfiForms
-
Reporting plugin
This is a workaround by using Confluence user macro to redirect the output of the encapsulated macros as the date paramater for the Countdown macro
The date format generated by the other macros must follow the format of dd-mm-yy.
Otherwise, additional preprocessing steps can be added in the user macro code
Instructions
Setting up the user macro
-
Log in as Confluence Admin
-
Go to Confluence Administration > General Configuration
-
Click on User Macros on the left side menu
-
Click on Create a User Macro
-
Fill in the details as the table below
Macro Name
countdownbody
Visibility
Visible to all users in the Macro Browser
Macro Title
Countdown Date in Body
Description
Uses the output of other macros as the date input to the Countdown Timer plugin
Categories
Visuals & Images
Icon URL
Documentation URL
Macro Body Processing
Rendered
Template
## Macro title: Countdown Date in Body ## Macro has a body: Y ## Body processing: Rendered ## ## @noparams #set ($index = $body.indexOf('</span>')) #set ($index = $index - 8) #if ($index > 0) #set ($startIndex = $index - 8) #set ($date = $body.substring($startIndex, $index)) #else #set ($date = $body) #end <ac:structured-macro ac ac:name="countdown" ac:schema-version="1"> <ac:parameter ac:name="countdowndate">$date</ac:parameter> <ac:parameter ac:name="centered">true</ac:parameter> <ac:parameter ac:name="style">Black</ac:parameter> </ac:structured-macro>
-
Click on Save button
Using the user macro
-
Go to the page or template
-
Add the Countdown Date in Body user macro instead of Countdown macro
-
Add the other macros which will provide the date
Plain Date
Other Macro