Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to display the workspace Key on a page?

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

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

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.

Do you have HTML macro enabled in your Confluence instance?

AJS.params.spaceKey

contains this info....

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
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

1,095 views 8 44
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you