Pass label as a parameter to page or blog creation?

andrey dmitriev
Contributor
July 25, 2011

Is it possible?

e.g. createPage?label=fruity, or createBlog?label=juicy

u get the point

1 answer

1 accepted

1 vote
Answer accepted
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 10, 2011

Its not part of the default confluence functionallity. But... my first thought is to solve this with a tiny bit of javascript. Insert this code to the Confluence Administrations 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) {
        
        //if yes is there a label given as request parameter???
        var label = getUrlVars()["label"];
        if(label) {
            
            //simply click the labeleditbutton
            jQuery("#labels_edit_link").trigger("click");
            //insert the label parameter value
            jQuery("#labelsString").val(label);
            //and close the label editor
            jQuery("#labels_edit_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>

This snippet of code is getting activated on a create page action. It looks for a "label" parameter and insert it to the labels input field. It works during a quick test in my CF 3.5.13.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events