June 23, 2009

0

Add Tag Cloud In Blogger Blog

  • June 23, 2009
  • anand
  • Share
  •  

    TAG CLOUDtagcloudI wondered a lot about having a tag cloud widget in my blogger blog. I ultimately, after a huge Google organic search got my self a tag cloud in my blog. I would like to share the same with you all.

    First of all login to your Blogger account and then follow this path layout>> add widget

    Then select the "label" option from the window. click save and view the blog.

    Now again follow the path layout>> Edit HTML
    Check the "expand widget" box

    Search for the line

    <b:widget id='Label1' locked='false' title='Tags' type='Label'>

    in the template code or find for the word "label" in the template code as the code may vary.

    *Replace the code with the following code snippet

    <b:widget id='Label1' locked='false' title='Tags' type='Label'>
    <b:includable id='main'>
    <b:if cond='data:title'>
    <h2><data:title/></h2>
    </b:if>
    <div class='widget-content' style='text-align: justify;'>
    <script type='text/javascript'>
    /*
    Simple Blogger Tag Cloud Widget
    by Raymond May Jr.
    http://www.compender.com
    Released to the Public Domain
    */
    //Settings / Variables
    var max = 150; //max css size (in percent)
    var min = 70; //min css size (in percent)
    var showCount = false; // show counts? true for yes, false for no
    var minCount = 1; // what is the minimum count for a tag to be shown? 1 for all
    //Begin code:
    var range = max - min;
    //Build label Array
    var labels = new Array();
    <b:loop values='data:labels' var='label'>
    labels.push("<data:label.name/>");
    </b:loop>
    //URLs
    var urls = new Array();
    <b:loop values='data:labels' var='label'>
    urls.push("<data:label.url/>");
    </b:loop>
    //Counts
    var counts = new Array();
    <b:loop values='data:labels' var='label'>
    counts.push("<data:label.count/>");
    </b:loop>
    //Number sort funtion (high to low)
    function sortNumber(a, b)
    {
    return b - a;
    }
    //Make an independant copy of counts for sorting
    var sorted = counts.slice();
    //Find the largest tag count
    var most = sorted.sort(sortNumber)[0];
    //Begin HTML output
    for (x in labels)
    {
    if(x != "peek" && x != "forEach" && counts[x] >= minCount)
    {
    //Calculate textSize
    var textSize = min + Math.floor((counts[x]/most) * range);
    //Show counts?
    if(showCount)
    {
    var count = "(" + counts[x] + ")";
    }else{
    var count = "";
    }
    //Output
    document.write("<span style='font-size:" + textSize + "%'><a href='" + urls[x] + "' style='text-decoration:none;'>" + labels[x] + count + "</a></span> " );
    }
    }
    </script>
    </div>
    </b:includable>

    </b:widget>


    Save the template and you will be having your tag cloud

    0 Responses to “Add Tag Cloud In Blogger Blog”

    Subscribe