Should passing the URL parameters for createblogpost.action work with Confluence 4.0 as well?

I have been using this kind of URL links with previous versions of Confluence:

.../wiki/pages/createblogpost.action?spaceKey=space&labelsString=label

It seems that the labels parameters are not passed on for the blog post at all anymore.

Is there any way to get this working with Confluence 4.0?

2 answers

This should still work in Confluence 4.0 with the parameter labelsString, it works at least in our environment. They won't be displayed in the label editor, but they will be added to the page/blogpost after saving.

I'm not sure whether this is a bug or a feature. You can pass multiple labels with labelsString=test1,test2 and then even add a third label (for example: label3) in the editor. Confluence will add all three labels to the page/blogpost. I can think of some use cases where hiding those passed labels would make sense.

Hope this helps

Remo, thanks a lot! This resolves my issue completely. It is actually even BETTER that the label parameters passed over in URL are not shown in label editor (the user cannot remove them...).

Exactly, that's the use case I was thinking about. I'm glad that this resolves your issue!

&labelsString=label doesn't work in 4.3

or should I still insert the script code for it to work?

It still works, without any script code. Just use the following url:

http://path.to.your.confluence/pages/createblogpost.action?spaceKey=TEST&labelsString=label1,label2

Note that the labels are not displayed in the editor during the creation of the blogpost. But they will be visible after saving.

I actually tested that for several minutes before posting my initial reply.

I didn't insert the code through the admin panel.

I use the abovementiond url with corrections to my server url and spacekey, it doesn't show the labels in the labels and it doesn't show them after I publish the post either...

I also tried the user macro to do that that is in the user macro repository or something here on Atlassian website, it also doesn't add the labels.

Strange, I just successfully tested it in three different Confluence instances with different users and different permissions. Can you confirm that you are able to add a label to a blogpost over the default UI?

Yes, sure I can add labels. I even use links on my webpages that create _pages_ in a specified space and with a specified template, that works fine, confirming it's not a browser issue (stripping redirects or whatever).

I'm using a standalone Confluence 4.3. The only code I added to the Custom HTML is the javascript to swicth off Notify watchers.

Are there any other parameters I could test with the createblopost.action to make sure they pass or not?

Thanks.

There are other parameters like spaceKey, but I'm sure they'll work. Sorry, don't really know what to do here, maybe check the log for any errors or contact Atlassian support.

Remo, sorry I was incorrect.

Indeed it works and passes labels on blog creation. Don't know why it didn't work for me yesterday evening, but it does today's morning.:) I'm planning to add some convenient buttons with those links.

Thanks.

Yes you can do this with a little bit of javascript. Insert the following code to your Administration > Custom HTML > "At the end of the BODY"-part

<script type="text/javascript">
 
AJS.toInit(function ($) { 
 
     //is it a create page action which is called?? 
    if( window.location.href.indexOf("createpage.action") > -1 || window.location.href.indexOf("createblogpost.action")) {
         
        //if yes is there a label given as request parameter???
        var label = getUrlVars()["labelsString"];
        if(label) {
             
            //simply click the labeleditbutton
            jQuery("#rte-button-labels").trigger("click");
            //insert the label parameter value
            jQuery("#labelsString").val(label);
            //and close the label editor
            jQuery("#add-labels-editor-button").trigger("click");

            jQuery(".dialog-button-panel a.button-panel-cancel-link").trigger("click");

        }
    }
});
 
//this function is needed to get the parameters from the url
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
 
</script><br><br>

Now you can use your "labelsString" Parameter. Don't forget to clear your browser cache with Ctrl+R. Testet with my Confluence 4.0.

It looks like the URL method is broken again (Confluence 5.9.3).

Sandro, your solution works perfectly for me (thank you!), but the labels window remains open after clicking the link.

I tried changing ".dialog-button-panel a.button-panel-cancel-link" to a couple of different things, but nothing I tried worked.  

Any ideas?

We experience the same problems  with the url method in5.9.4. Anyone any ideas how to solve it.

see https://jira.atlassian.com/browse/CONF-37848

A solutiion that fixes the url method is installing the recently published free Bitvoodoo add-on Label Fixer

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

976 views 23 13
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you