The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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 Champions.
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 HP
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 Champions.
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
TAGS
AUG Leaders

Atlassian Community Events