Page tree
Skip to end of metadata
Go to start of metadata
Macro SummaryMake Confluence pages dynamic, with content depending on user input, with a parameter macro.
What it looks like

displays here as:

123

Try adding '?intparam=321' to the URL to change this.

Description

Macro 

## @param param:title=Parameter|type=string|required=true|desc=URL Parameter to capture
## @param default:title=Default Value|type=string|required=false|desc=Number value if no param is set.
## @param adjust:title=Numeric Adjustment|type=int|required=false|desc=Amount to increase or decrease (if negative) param value by.
## Consider blank equal to non-existent.
#if($req.getParameter($paramparam) && $req.getParameter($paramparam)!='')
#set(  $p=$req.getParameter($paramparam))
#if(  $stringUtils.isNumeric($p))
#if(    $paramadjust)
#set(      $adjustVal=0)
#set(      $adjustVal=$adjustVal.parseInt($paramadjust))
#set(      $modVal=0)
#set(      $modVal=$modVal.parseInt($p))
#set(      $p=$modVal+$adjustVal)
#end
$!p
#else
Error: Parameter $paramparam is not a number.
#end
#else
$!paramdefault
#end

Does it work?

Edit a Confluence page, and insert:

Save, edit the URL and add ?sprint=123. You should see the result: