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

Juha Meronen November 29, 2011

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

2 votes
Remo Siegwart
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.
November 29, 2011

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

Juha Meronen November 29, 2011

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...).

Remo Siegwart
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.
November 29, 2011

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

KPAH
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.
October 29, 2012

&labelsString=label doesn't work in 4.3

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

Remo Siegwart
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.
October 29, 2012

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.

KPAH
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.
October 29, 2012

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.

Remo Siegwart
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.
October 29, 2012

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?

KPAH
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.
October 29, 2012

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.

Remo Siegwart
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.
October 30, 2012

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.

KPAH
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.
October 30, 2012

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.

1 vote
Sandro Herrmann [Communardo]
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.
November 29, 2011

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.

eyrisone February 25, 2016

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?

Ingrid Schipper March 14, 2016

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

Auke_Miedema March 14, 2016

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
TAGS
AUG Leaders

Atlassian Community Events