Forums

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

Conditional dynamic display of macros - possible?

Sven
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.
December 8, 2011

Hello,
I'm searching for a way to do in confluence something like this:
IF checkbox xyz is checked then
display "{livesearch} limited to current space"
else
display "{livesearch}"

Is something like this possible?
I imagine I could get this done with some "jquery-magic" (and the html-macro), but perhaps there a existing (user-)macros for this kind of task?

Thanks in advance for any hint!

Bye
Sven

2 answers

1 accepted

0 votes
Answer accepted
Bob Swift
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.
December 8, 2011

You can use the Run Plugin to do things like this. In more complex cases, you may need some some additional logic using Confluence Script Plugin or other similar macros.

Sven
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.
December 8, 2011

wow, that looks powerful, I'll try this out! Thanks!

(although I've stepped some time ago through all confluence plugins, I've missed this one ;-)

Sven
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.
December 8, 2011

could you give me a quick hint:

I try:

{run:autorun=true|replace=
year:::checkbox::SEO:SEO} 
livesearch:spaceKey=$year
{run}

...and when I click on the link, it replaces the correct word but in '' (which cases it to fail) - Why?

livesearch:spaceKey='SEO'

(I will add the {livesearch:spaceKey='SEO'} later...

Bob Swift
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.
December 8, 2011

Checkbox is a multi-select control, so use suppressQuote=true to avoid in your case - see Run macro documentation.

Sven
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.
December 8, 2011

Thanks for the answer!

I'm a developer, and I was digging through the documentation, but I didn't figure this out... Are there somewhere more samples than that:

https://studio.plugins.atlassian.com/wiki/display/RUN/Release+notes+2.0

Anyway, I've formulated it the other way round in the meantime and it's working well:

{run:autorun=true|titleRun=Go|replace=
space:SEO:search everywhere:checkbox:30:'':''} 
{livesearch:spaceKey=$space}
{run}

And I added some jQuery-Magic to make an Form-Submit on checking the checkbox:

(must go to CustomHTML in head):

<script>
jQuery(document).ready(function() {

    //jQuery('input[type="button"][value="Go"]').hide(); 

    jQuery('input[name=run_1_space]').click( function(e){
         jQuery(this).closest('form').submit();
     });	
});
</script>

This way I've added even some "ajax" ;-)

Now... the only thing I'm struggling with is:

- to get rid of the tables in your run-macro

- to get rid of the "submit"-Button

I've tried to do it by jquery, but the table in the run-macro has no "custom class" (just confluence-table) and the submit-button has no custom id...

...or did I miss some settings in your incredible useful macro?

Bob Swift
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.
December 8, 2011

Look through the parameters on the documentation page Run macro , for instance - hideRun, hideColumnHeadings, parameterInput.

Benoit LOUZAS
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 25, 2018

Hello,

I would like to do something similar to the feature you've explained.

I have 2 documents (template A, template B) with check lists that are almost the same at 90%.

I want to create one document/template, with info from both A and B, so I need to do something like Sven did

IF checkbox xyz is checked then
display "paragraph specific A"
else
display "paragraph specific B"

but the link you gave, for the Run Macro and Script Plugin are not working. Is this not supported anymore?

Thanks in advance

Benoit

0 votes
Bob Swift
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.
December 8, 2011

Checkbox is a multi-select control, so use suppressQuote=true to avoid in your case - see Run macro documentation.

Sven
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.
December 8, 2011

Thanks for the answer!

I'm a developer, and I was digging through the documentation, but I didn't figure this out... Are there somewhere more samples than that:

https://studio.plugins.atlassian.com/wiki/display/RUN/Release+notes+2.0

Anyway, I've formulated it the other way round in the meantime and it's working well:

{run:autorun=true|titleRun=Go|replace=
space:SEO:search everywhere:checkbox:30:'':''} 
{livesearch:spaceKey=$space}
{run}

And I added some jQuery-Magic to make an Form-Submit on checking the checkbox:

(must go to CustomHTML in head):

<script>
jQuery(document).ready(function() {

    //jQuery('input[type="button"][value="Go"]').hide(); 

    jQuery('input[name=run_1_space]').click( function(e){
         jQuery(this).closest('form').submit();
     });	
});
</script>

This way I've added even some "ajax" ;-)

Now... the only thing I'm struggling with is:

- to get rid of the tables in your run-macro

- to get rid of the "submit"-Button

I've tried to do it by jquery, but the table in the run-macro has no "custom class" (just confluence-table) and the submit-button has no custom id...

...or did I miss some settings in your incredible useful macro?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events