အထက္ပါ ေခါင္းစဥ္ကို ကလစ္ႏွိပ္၍ ဤပို႔စ္၏ လမ္းၫႊန္မႈအတုိင္း ျပဳလုပ္ပါ။ အကယ္၍ ယခင္က Json Javascript ထည့္သြင္းၿပီးျဖစ္ပါက ထပ္မံ၍ ထည့္သြင္းရန္ မလုိအပ္ေတာ့ပါ။
အဆင့္ (၂) "Latest Post" Widget ထည့္သြင္းျခင္း
ေအာက္တြင္ ေဖာ္ျပထားေသာ Code အား </b:widget> ႏွင့္ <b:widget id= ......... အၾကားတြင္ ထည့္ေပးပါ။
<b:widget id='HTML101' locked='false' title='Latest Posts' type='HTML'>
<b:includable id='main'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
<ul><div id='dataPost'/></ul>
</div>
<script type='text/javascript'>
// Developed by Hoctro - All rights reserved 2007
// This credit must be included in all your derived usages.
// This widget lists the available posts based on the uP.nPost value below
// Use -1 if you want them all.
var uP = {
nPost : -1
};
var cP = {
// private variable to store the total results
totCount : 0,
// the number of elements for each json call
increment : 10,
// this is the place to define the blog name for subsequent retrieval data
web : "pikay.myanmarbloggers.org",
listPosts: function(json, tag) {
var text="";
for (var i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
text += "<li>" + "<a href='" + cb.getLink(entry, "alternate")
+ "'>" + cb.getTitle(entry) + "</li>";
}
var p = document.createElement('span');
document.getElementById(tag).appendChild(p);
p.innerHTML = text;
},
callPostJson: function(json) {
this.listPosts(json, "dataPost");
},
getCo : function(json) {
this.totCount = cb.getTotalResults(json);
var count = (uP.nPost < 0) ? this.totCount : uP.nPost;
var i=1;
while(i<=count) {
var incr = (count-i < this.increment) ? count-i+1 : this.increment;
cb.search( cP.web, "posts", i, incr, 'cP.callPostJson');
if (incr==0) incr=incr+1;
i = i+incr;
}
}
};
cb.search( cP.web, "posts", 1, 2, 'cP.getCo');
</script>
</b:includable>
</b:widget>
အထက္ပါ Code တြင္
var uP = {
nPost : -1
};
မွ -1 ေနရာတြင္ မိမိေဖာ္ျပလိုေသာ ပို႔စ္ အေရအတြက္အား သက္မွတ္ရန္ျဖစ္သည္။
-1 ဟု သက္မွတ္လိုက္လွ်င္ ပို႔စ္ အကန္႔အသတ္ မရွိ ေဖာ္ျပရန္ သက္မွတ္ျခင္းျဖစ္သည္။
ထုိေနာက္ pikay.myanmarbloggers.org ေနရာတြင္ မိမိ၏ ဘေလာ့ လိပ္စာ ထည့္ရန္ျဖစ္သည္။
No comments:
Post a Comment