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?

Thanks!

1 answer

1 accepted

1 vote
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 <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

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!

Rachel

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

377 views 20 10
Join discussion

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