Pass parameters between pages

ericjeedunn June 14, 2016

Want to do basically add programatic logic to pages, based on passing parameters.

Say page 1 has a link to page to like http://.....page2?custom_param=value

Page 2 I want to get that parameter, and display only parts of the page that I want (basically hacking the macros include page and include excerpt to be more powerful). Would involve getting the parameter, and being able to do conditional logic as well.

Anyone know how? Seems like there were some questions asked in the forum but no answers.

If not, is there a way to write a custom macro to do parameter retrieval, and conditional display logic?

2 answers

0 votes
Robert Massaioli _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 14, 2016

Are you writing an Atlassian Connect add-on? If so can you be more explicit in what you are trying to do?

0 votes
Davin Studer
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.
June 14, 2016

Since you are on Confluence Cloud there is not much you can do. With the server version you could do this easily with a user macro.

ericjeedunn June 14, 2016

How would you do it as a macro? Do you have sample code? What about conditional logic, if x then display y?

Thx so much!!

Davin Studer
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.
June 14, 2016

Are you indeed using confluence cloud? If so you cannot do what you are asking. If you have the server version it is possible, but the cloud version is locked down.

Mike Desilets March 7, 2019

Davin - I am using Confluence Server and would be interested in a code example for how to do this in a User Macro. 

Davin Studer
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.
March 8, 2019

Sure, here is an example of a user macro I created that when the macro is put on a page and the url ends with ?frameable=true then the page will be displayed without all the Confluence navigation and will only show the content of the page. The key part is on line 5 where it checks the URL querystring for the parameter "frameable".

## Developed by: Davin Studer
## Date created: 04/02/2015
## @noparams

#if($req.getParameter('frameable') == "true")
    #set ($p = '#')

    <style>
        ${p}header, ${p}footer, .ia-splitter .ia-splitter-left, ${p}labels-section, ${p}comments-section, ${p}sidebar-container, ${p}main-header, ${p}content .page-metadata {display: none !important;}
        ${p}main {margin-left: 0 !important; border: 0 !important; padding: 0 !important;}
        html, body, ${p}full-height-container .ia-splitter, ${p}main, ${p}content, ${p}main-content {height: 100% !important; padding: 0 !important; margin: 0 !important; box-sizing: border-box !important; position: absolute !important; top: 0 !important; left: 0 !important; width: 100% !important;}
        body {background: ${p}FFFFFF !important;}
        ${p}main-content {padding: 0px 10px 0px 10px !important;}
    </style>
#end

If you wanted the pass a varible into a user macro through the querystring you could do this. You now have a variable called $myVar that can be used in your user macro.

#set $myVar = $req.getParameter('parameter')

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events