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?

Thanks

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,'');
		jQuery('#prevnext').empty().append(panel);
		jQuery('#prevnext').insertBefore('#main-header');
	&lt;/script&gt;

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.toInit(function(){
  AJS.$('.wiki-content').append("&lt;p&gt;&lt;a href='http://www.google.de'&gt;Hello World!&lt;/a&gt;&lt;/p&gt;");
});      
&lt;/script&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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

495 views 19 10
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