[教學]Blogger如何簡單的加入標籤雲的語法...

想在你的blogger加入tag cloud 嗎?

這個方法只適合于new blogger.

先決條件,你的blogger必須要有label分類。

如果沒有的話,就加入一個吧!

1. 登錄blogger,點按『dashboard』-》『layout』-》『Add a Gadget』,選擇『labels』

2. 加入后,點按『edit HTML』,然后找到下列程式碼。然后點按『save template』即可。

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

3. 把上述程式碼改換成如下。


<b:widget id='Label1' locked='false' title='標籤雲' 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
*/


//Variables:


var max = 150; //max css size (in percent)
var min = 50; //min css size (...)
var showCount = 1; // show counts? 1 for yes
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" &amp;&amp; x != "forEach" &amp;&amp; counts[x] >= minCount)
{


//Calculate textSize


var textSize = min + Math.floor((counts[x]/most) * range);


//Show counts?


if(showCount == 1)
{
var count = "(" + counts[x] + ")";
}else{
var count = "";
}


//Output


document.write("<span style='font-size:" + textSize + "%'><a href='" + urls[x] +
"'>" + labels[x] + count + "</a></span> " );
}
}
</script>
</div>
</b:includable>
</b:widget>

此程式碼由 Raymond May Jr. 提供。

留言