How to apply a macro globally

ashan April 23, 2013

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

2 votes
Stefan Eike
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.
April 23, 2013

Ah, Bob explained it in this thread.

1 vote
Steve Goldberg
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.
May 21, 2013

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

0 votes
ashan April 23, 2013

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

Stefan Eike
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.
April 23, 2013

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.

0 votes
ashan April 23, 2013

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

Stefan Eike
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.
April 23, 2013

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

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 23, 2013

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.
0 votes
ashan April 23, 2013

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

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 23, 2013

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

0 votes
Stefan Eike
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.
April 23, 2013

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events