How to apply a macro globally

Hi all,

I want to apply the <Next/Previous> macro to all pages in a space without having to include the macro to each and every page manually. Is there a way to do this please?


8 answers

Ah, Bob explained it in this thread.

I had the same issue. Here's what I did:

  1. Put the macro in the header of the theme.
  2. Put similar jQuery that Stefan mentions above directly into the macro itself (that way it only runs when the macro does).

My code is:

&lt;script type="text/javascript"&gt;
		var panel = jQuery('#prevnext').html().replace(/&amp;nbsp;/g,'');

This assumes you've put a wrapper around the whole of the prev/next button output with the ID of "prevnext".

Hmm... that's an interesting task. Maybe it's possible by modfying the theme? Maybe with some JQuery injecting the content you'd like to have. Unfortunately I don't have a usable code snippet for you ATM.

You should be able to do with with the Documentation theme.

Yes I am using the confluence documentation theme. But I don't know how to do this.

Sorry, I should have provided more details.

  1. Go to Space Admin -> Themes -> Configure Theme
  2. Add your macro (I use scrollbar) in the Messages header section.

Thanks. Only problem is, I don't want this macro added in the header section. I want to add it to the page's content section (the body).

Maybe you should put it in the footer, use it in a (live-)template or inject it with JQuery into the body.

Do you have a sample on how to inject the macro with JQuery into the body please?

Hmm... you can add something like that to the At end of the HEAD section at Look and Feel > Custom HTML in the Admin panel.

&lt;script type="text/javascript"&gt;
  AJS.$('.wiki-content').append("&lt;p&gt;&lt;a href=''&gt;Hello World!&lt;/a&gt;&lt;/p&gt;");

But you can only add (X)HTML like that. If you want to add a macro to the body, place it to the header section, like Bob mentioned, and than cut and paste it with JQuery to where you want it to live after the page has rendered.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Tuesday in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

252 views 2 10
Read article

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