Confluence User Macro: Passing Param From Macro #1 to Macro #2

JamesR March 15, 2013

Confluence 5.0.1 Download Version

Summary: Two different User Macros on a single page. Is it possible to - dynamically - pass a user entered param from one macro to another?

Detail:

  • Page Name = "I'm New Here"
  • User Macro #1 = UM1
    • Param = p1
  • User Macro #2 = UM2
    • Param = p2
  • Is there a method / code to set p2 equal to the entered value for p1?

Thank you for your consideration --- I promise to provide any additional clarification and am open to any other ideas.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

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.
April 3, 2013

If the second user macro just executed client side/javascript based on the HTML in the first, then what you want could be achieved. It all depends on what these user macros actually do.

JamesR April 3, 2013

Hi David,

Thanks so much for your guidance. Please forgive me, my technical skills are definitely lacking. Here's my initial attempt to answer your thoughtful proposition. Please let me know if I am leaving anything out and if you believe my goal could be achieved via some other approach.

  • High-Level Goal
    • When a developercreates or edits a Confluence page, we'd like some sort of Header and Footer on the page.
  • Detail-Level
    • Header
      • The developer would NOT design the Header.
      • The developer would simply select (from a drop-down box) one of the following:
        • Internal Use
        • External Use
        • Divisional Use
        • Department Use
      • Based on the drop-down box selection, a page Header would be created with some minor formatting.
      • The Header would be viewable by page reader, not editable.
    • Footer
      • The developer would NOT design the Footer and would have no interaction with the Footer (other than to view it in the Preview stage of the Confluence save process)
      • The Footer would be a formatted string of the selection made in the Header plus the text "Official End of Document"

Using the Macro, I can create the Header that fits our needs perfectly; but I've no approach for the Footer.

Am I going about this in the wrong way?

Thanks for your consideration!

Sincerely, CR

1 vote
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 3, 2013

Hi Tyler,

This is not easily achieved in Confluence since the parameters in a macro are not "dynamic". The entered values for a macro parameter are saved in the page just like any other page content, so Confluence does not have any mechanism to change their value automatically based on the state of the other content in the page.

If you really needed this to work, your User Macro #2 would need to retrieve the whole content of the page and parse it manually, looking for User Macro #1 and reading in the stored parameter value. It would be possible to do this using the Confluence PageManager, but it would be quite a bit of coding and I'm not sure how well it would perform.

Joe.

JamesR April 3, 2013

Hi Joseph,

Thank you so much for your insights and guidance. Your approach - via page parse - gives me hope that I can make this work.

Thanks again, take care, CR

0 votes
Hatem Ounis August 8, 2013

I'm also interested in the dynamic values of a drop-down box in macro params, so any answer to this s far ?

0 votes
JamesR March 18, 2013

As another idea / question: would it be possible to set a User Macro param to some value on the Confluence page?

Example: I have a Confluence page with a drop down box containing three choices (A, B, C). Is is possible to have a User Macro render based on the choice made from the drop down box (A, B, C)?

Thanks for your consideration.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events