Is there a shortcut way to use 2 macros together?

We're using Confluence for some product documentation. The documentation has lots of chunks of text that are reused in various places, so we're using "Include Page" to pull them into the right place. But every time we pull them into the page we also want the chunk to be expandable/collapsible, so we're using the expand macro.

This means that every time we pull a chunk of text in we have to use 2 macros separately, like this:

expand "Chunk title"

include page "Chunk title"

There are thousands of these chunks, so it's very tiresome doing this repeatedly.

Is there a way we can combine the expand and include together in a shortcut, to speed this up?


1 answer

1 accepted

1 vote
Answer accepted
David Simpson Community Champion Jun 19, 2013

Try this user macro:

## Macro title: Expand and Include Page
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
## Developed by: David Simpson, AppFusions <>
## Date created: 2013-06-20
## Installed by: My Name

## See:
## Source:

## This is an example macro
## @param Name:title=Page Name|type=string|required=true|desc=Your page name
## @param SpaceKey:title=Space Key|type=string|desc=Add the space key if including from another space

  #set($includeName = "$paramPacekey:$paramName")
	#set($includeName = $paramName)
<ac:macro ac:name="expand">
	<ac:parameter ac:name="title">${paramName}</ac:parameter>
		<ac:macro ac:name="include">

Updates here:

More on user macros:,+Editing+and+Removing+User+Macros

Thanks David, I'll give it a try!

Hi David,

I had a go with this but so far get a message saying "Unable to render {include} The included page could not be found." I guess I'm doing something silly with the way I'm entering page names (using a wildcard hasn't helped either) but just to check: is there any particular trick to entering page names correctly?

Also, it turns out we're likely to use the "excerpt include" macro, not the "page include" one ... so the user macro will need to be adjusted for this. It'll still help to get the page include working first, though.

Thanks again for your help!


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

1,499 views 4 13
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you