Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

pass URL parameters to html-include macro

Thilo July 20, 2020 edited

I'm using html-include to call a small php script and embedd the output into a confluence page (following the desctiption on https://confluence.atlassian.com/confkb/how-to-use-php-inside-confluence-pages-317197666.html).
It works fine and I see the output of the php script.
But is there a possibility to pass parameters from the URL of the confluence page (?variable=content) through to the embedded php script?  

1 answer

1 accepted

0 votes
Answer accepted
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 20, 2020

Have you looked at creating a user macro that holds the PHP script? That would give you the ability to have parameters/settings, plus access to page objects.

Thilo July 20, 2020

Thanks a lot. Since I'm totally new to Confluence I think I need a push in the right direction. I just checked the documentation of user macros and the examples from the documentation. The point which is not yet clear to me is, how to call the php script from within a user macro. Can I use the html-include macro within a user macro (if yes, how?) or is there a different way to do it?

Thilo July 20, 2020

Or should I create an iframe in the user macro which calls the php script?

Thilo July 21, 2020

I solved the problem. Found a posting in the community which explained how to call a macro from within a user macro and some other helpfull postings to solve the remaining poroblems.  
Here is the summary just in case someone else has the same question:

I got the GET parameters from the url with 

#set($foobar = $generalUtil.urlEncode($req.getParameter("foobar")))

Then I added the html-include macro pointing to my php script into a temporary page. Got the saved source for this temporary page and pasted it into my user macro where I then added ?foobar=$!foobar to the URL. 

Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2020

User macros are your friends, and very powerful. I have macros that also call Javascript to provide action buttons on the page while in view mode.

I wrote this article some time back, and need to add more:

Getting-Started-with-User-Macros-Writing-a-Wrapper-Macro 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events