Space key and page name Confluence User Macros

When developing space and page templates it is sometimes necessary to add the current space key or page name as information into the page based on a template. E.g. one wants to display a list of blog posts (e.g. using the Blog Posts Macro) of the current space on the space home page and you are using a page template for this. You can change the space key each time when a new page is created from the template but this is error prone and not very user friendly.

Luckily Confluence has a nice feature which allows to define User Macros which allow to extend Confluence in a easy way.

Note: The following actions require administration permissions.

Space Key User Macro

In order to define a user macro which adds the current space key perform the steps as documented at User Macros using the following parameters:

Macro Name: spacekey
Macro Title: Space Key
Description: Adds the current space key as text
Category: Confluence Content
Macro Body Processing: No macro body
Output Format: HTML
Template: $space.getKey()

You can now use the macro on any Confluence page using {spacekey}.

Page Name User Macro

In order to define a user macro which adds the current page name perform the steps as documented at User Macros using the following parameters:

Macro Name: pagename
Macro Title: Page Name
Description: Adds the current page name as text
Category: Confluence Content
Macro Body Processing: No macro body
Output Format: HTML
Template: $content.getTitle()

You can now use the macro on any Confluence page using {pagename}.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s