Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create a custom Button on the Confluence Header

fkoehn April 24, 2020

Hey all!

 

i'm trying to create a new custom Button to create a blogpost in whatever space the user is currently visiting.

I have found:

<script>
AJS.toInit(function(){
    AJS.$('.aui-header-primary .aui-nav').append('<li><a href="http://www.atlassian.com" class=" aui-nav-imagelink">Atlassian</a></li>');
});
</script>

wich does create a Button with a Link to Atlassian but what i try to reach is:

/pages/createblogpost.action?spaceKey=AJS.params.spaceKey

AJS.params.spaceKey is the Javascript part that gets the SpaceKey.

How can i combine the HTML href command with the Javascript ?

Thanks in advance

 

 

1 answer

1 accepted

3 votes
Answer accepted
Dominic Lagger
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.
April 24, 2020

Hi @fkoehn 

You almost gave yourself the answer :) 

You have to concatenate the spacekey and the link:

<script>
AJS.toInit(function(){
AJS.$('.aui-header-primary .aui-nav').append('<li><a href="/pages/createblogpost.action?spaceKey='+AJS.params.spaceKey+'" class=" aui-nav-imagelink">Create Blog Post</a></li>');
});
</script>

Regards, Dominic

fkoehn April 24, 2020

Hey @Dominic Lagger 

I had the same exact answer figured out but i had to reload the page once to actually reach the site to create Blogposts. your Code works though.

Trying to figure out why now.

Thank you very much!

Michelle Rau good
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.
May 14, 2021

@Dominic Lagger this is exciting, I was able to use this to add a "button" to a space header that creates a page from a specific template. Awesome!

Like Dominic Lagger likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events