Is there a shortcut way to use 2 macros together?

Steve Reynolds June 19, 2013

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?

Thanks!

1 answer

1 accepted

1 vote
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 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 <david@appfusions.com>
## Date created: 2013-06-20
## Installed by: My Name

## See: https://answers.atlassian.com/questions/182288/is-there-a-shortcut-way-to-use-2-macros-together
## Source: https://gist.github.com/dvdsmpsn/5822321

## 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

#if($paramSpace)
  #set($includeName = "$paramPacekey:$paramName")
#else
	#set($includeName = $paramName)
#end
<ac:macro ac:name="expand">
	<ac:parameter ac:name="title">${paramName}</ac:parameter>
	<ac:rich-text-body>
		<ac:macro ac:name="include">
			<ac:default-parameter>${includeName}</ac:default-parameter>
		</ac:macro>
	</ac:rich-text-body>
</ac:macro>

Updates here: https://gist.github.com/dvdsmpsn/5822321

More on user macros:
https://confluence.atlassian.com/display/DOC/Adding,+Editing+and+Removing+User+Macros

Steve Reynolds June 19, 2013

Thanks David, I'll give it a try!

Steve Reynolds June 20, 2013

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!

Rachel

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events