How to display the workspace Key on a page?

Dirk Eyfrig December 9, 2021

I need to display on a page the key of the workspace the page belongs to. When moving the page to another workspace, it should automatically display the key of that new workspace.

In a Confiforms environment I would use [entry._page.spaceKey], but I want to avoid using confiforms just for this.

How can I achieve this without using Confiforms? 

 

1 answer

1 accepted

0 votes
Answer accepted
Alex Medved _ConfiForms_
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.
December 9, 2021

Have you considered creating a simple user macro to do that?

$content.spaceKey

contains this... https://confluence.atlassian.com/doc/user-macro-template-syntax-223906130.html

Dirk Eyfrig December 9, 2021

Hi Alex,

you seem to be active everywhere ;-), we just discussed about confiforms...

No, I didn't consider a user macro; I don't have access to user macros as I'm not a site admin.

I hoped there is a solution that can be implemented directly on pages. Our IT department is a bit reluctant on supporting user macros.

Alex Medved _ConfiForms_
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.
December 9, 2021

Do you have HTML macro enabled in your Confluence instance?

AJS.params.spaceKey

contains this info....

Dirk Eyfrig December 9, 2021

OK, got it. that works!
Thanks.

Sample code, where Key is displayed when a button is pressed - if anyone else is having the same issue and is not so familiar with scripting of html pages...

<script type="text/javascript"> 
function showMessage(msg) {
AJS.$('#spaceKey').html('Workspace key is: <strong>'+msg+'</strong>');
}
</script>

<button class="aui-button submit" type="button" onclick="showMessage(AJS.params.spaceKey)">Show Key</button>
<br />
<div id="spaceKey"></div>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events