Using a Confluence page as a base page for a user macro

If you’re using Confluence (like I do at work) and have been digging around the user macros feature, this might be something for you.

I wanted to create a user macro, which basically just inserts a parametrized confluence page. Googling for it, I didn’t find a thing noted about how one would create such a macro. So, now there is.

A Confluence user macro is basically a Velocity template with parameters, that are evaluated by Confluence and presented to the user in a nice UI. These parameters are stuck in „$param<Name>“ variables, that can be used in the template.

So, basically you first have to create a Confluence page somewhere and use that kind of parameters there (note the prefix $param!). Please check the storage format after saving your page and check, that the parameters really are in the text like they should. (I came across a problem when I entered a parameter and edited it later and Confluence threw in a „<span>“-Tag in that)

After that, create a user macro and enter these basic code:

## Specify the page, this macro is based on


## Specify the parameters for that page

## (...)

## Get PageManager object instance
## Get the Page object instance

## Render the page with the parameters above

Replace the words SPACE and Page with your actual Space- and Pagenames. Finally, define the parameters for that page at the (…)-place in the code and you’re ready to go.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.