How to prompt for page within Include Page macro?

This is my first user macro. I want it to include the Include Page macro. I got this example from the Confluence documentation:

 

<ac:structured-macro ac:name="include">
  <ac:parameter ac:name="">
    <ac:link>
      <ri:page ri:content-title="My chocolate page" ri:space-key="DOC"/>
    </ac:link>
  </ac:parameter>
</ac:structured-macro>

 This would work fine if I wanted the user macro would always connect to the same page, but I want mine to open a dialog and prompt for "Page to Include", the way the Include Page macro normally does.

I can't find the instructions to do that. I thought if I deleted the "ri" tag, it would prompt me, but that doesn't seem to work.

 

 

2 answers

1 accepted

1 vote
Stephen Deutsch Community Champion Aug 29, 2017

If you need to prompt for a page to include, then you have to include parameters in your user macro:

https://confluence.atlassian.com/doc/user-macro-template-syntax-223906130.html

and then you'll have to parse the result yourself. Here is a small example that should work:

## @param PageToInclude:title=Page to Include|type=confluence-content|required=true|desc=To specify a page in a different space, use SPACEKEY:Page Title.

#if ( $paramPageToInclude.indexOf(":") == -1 )
#set ( $spaceKey = $space.key )
#set ( $contentTitle = $paramPageToInclude)
#else
#foreach ( $part in $paramPageToInclude.split(":") )
#set ( $spaceKey = $part )
#break
#end
#foreach ( $part in $paramPageToInclude.split(":") )
#set ( $contentTitle = $part )
#end
#end

<ac:structured-macro ac:name="include">
<ac:parameter ac:name="">
<ac:link>
<ri:page ri:content-title="$contentTitle" ri:space-key="$spaceKey"/>
</ac:link>
</ac:parameter>
</ac:structured-macro>

I suspected there was a reason I should learn JavaScript...

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

2,916 views 27 12
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