Where/How to add macro (code) being available on EVERY Confluence page?
Asked by Markus Lepper:

I've created a small user macro which return the page id: *$content.getIdAsString()*   
Works quite well to add this to a page when in being in edit mode.

How, better where, to place this line to get this line automatically added (and non removalbe by users) to all confluence pages (in header or footer)?

Same question for external macros: I would like to have "Viewtracker" at bottom of every page.

I've tested "Admin \> Layouts \> Main layout", but did not find the right line where to add my code.

Did only get the macro-code renderdered as text (not executed) and often overlapping to the existing texts.

Thanks,  
Markus

PS: Unfortunately Atlassian "lost" all my karma points when merging twom accounts...


Answers:
author: Daniela Scheiwe
body: Hi! You can render macros here the same way you would use to render macros inside macros:

```
#set($globalHelper = $action.getHelper())$globalHelper.renderConfluenceMacro("{MYMACRO}")
```

There's even a $page variable available in the page layout, so you could even use this one directly instead of your macro code.

Regarding the "where" - look through the code of the "page" layout (and blog, if you need that too) to find your desired position, it's pretty linear and quite easy to understand.


author: Oli S
body: For the documentation theme, try to insert the viewtracker macro via "Space Admin" =\> "Themes" =\> "Configure Theme" into "Messages" header or footer.


author: Daniela Scheiwe
body: Hi, if you want it to be part of the breadcrumb navigation, you need to update the breadcrumbs.vm in C:\\Program Files\\Atlassian\\Confluence\\confluence\\breadcrumbs.vm. I've tested it with v5 of confluence but should be the same for v4.

At the end of the document look for

```
##        &lt;/li&gt;    #end    &lt;/ol&gt;&lt;/content&gt;
```

You can just add another \<li\> element between #end and \<ol\>. $page.id is working here, so

```
##        &lt;/li&gt;    #end	&lt;li&gt;$page.id&lt;/li&gt;    &lt;/ol&gt;&lt;/content&gt;
```

results in

![](http://i39.tinypic.com/5xsweo.png)

(no restart required for this)

comments: author: Markus Lepper
body: Thanks a lot Superuschi (Daniela? :-).

This works very well! Do you happen do know where to find more **page.xxx**properties; e.g. the tinyurl?

Greetings from DU to OB /Markus


author: Markus Lepper
body: On admin- and profile-pages unfortunately the "$page.id" does not get rendered but is shown as plain text.

Do these pages do not have a unique id?

Regards /Markus


author: Markus Lepper
body: @Superuschi

This works, thanks!

I need to change the position, though.

The pageid and TinyURL shall be presented after the page breadcrump list

Pages / Level 1 / level 2 / instruction (PageID: xxxxx, URL: yyyyy)

I've read a lot but still am confused (due to missing knowledge) what constructs to use:

#set($globalHelper = $action.getHelper())

$!globalHelper.renderConfluenceMacro("{getpageid}")

or $sitemeshPage.getProperty("page.pageID") or similar

or ${page.id}

or {page-info:tinyurl}

or `AJS.$(``"#pageId"``).val()`

or ...

Nothing really works...

Thanks /Markus


author: Markus Lepper
body: Thanks Oliver..we are using the default theme where this options are n/a.

I still suppose adding "code" to "Admin \> Layouts \> Main layout" will help, but what and where?


author: Natalie Hobson
body: Put in a support ticket for the karma points problem - the same thing happened to me and they fixed it. :)


Tags: macro

template