Conditional dynamic display of macros - possible?

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

This widget could not be displayed.

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.

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 ;-)

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

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

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?

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

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

This widget could not be displayed.

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

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
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

625 views 8 6
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