Where/How to add macro (code) being available on EVERY Confluence page?

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

6 answers

1 accepted

This widget could not be displayed.

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.

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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?

This widget could not be displayed.

@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

This widget could not be displayed.

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

##        </li>
    #end
    </ol>

</content>

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

(no restart required for this)

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

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

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

601 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