Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 9, 2021 edited

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_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 9, 2021

Do you have HTML macro enabled in your Confluence instance?

AJS.params.spaceKey

contains this info....

Dirk Eyfrig December 9, 2021 edited

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
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events