Được đăng bởi :
Minh
|
Thứ Tư, 2 tháng 3, 2011
|
09:05:00
Tiện ích Bài viết Hot cho blogspot
Để cài đặt tiện ích này, bạn hãy thực hiện như sau.
Bước 1. Đăng nhập Blogger, vào Design >> Edit HTML. Đặt đoạn code bên dưới vào trước thẻ </head>.
<script type='text/javascript'>
//<![CDATA[
// Hot Posts Widget styled by Huynh-nhat-ha.blogspot.com
getHP=function(d){document.write(d)};
hotPost = function(u,t,c,b) { this.url = u; this.tit = t; this.comm = c; this.body = b };
var sortAllPosts=[];
sortAllPostsRecopilation = function (json) {
var total,entry,i,x,arr,lnk,com,ttle;
total = json.feed.entry.length;
for(i=0; i < total; i++){
entry=json.feed.entry[i];
for (x=0; x < entry.link.length; x++){
arr = entry.link[x];
lnk = (arr.rel=="alternate" ? arr.href : lnk);
if(arr.rel=="replies"){
com = (arr.type=="text/html" ? parseInt(arr.title,10) : com);
}
}
ttle = entry.title.$t;
txt = ('summary' in entry ? entry.summary.$t : entry.content.$t);
sortAllPosts.push(new hotPost(lnk,ttle,com,txt));
}
sortAllPosts=sortAllPosts.OrderMaxMin();
};
Array.prototype.OrderMaxMin = function(){
var max=0;
var tmp=[];
var x,i,post;
for(i=0; i<this.length; i++){
post=this[i];
max = ( post.comm > max ? post.comm : max);
}
for(x = max; x>=0; x--){
for(i=0; i<this.length; i++){
post=this[i];
if(post.comm == x){
tmp.push(post);
}
}
}
return(tmp);
};
Array.prototype.DisplayHotPosts = function(max,txt) { for(var i=0; i<max;i++){ p=this[i]; getHP(p.tit.link(p.url)+" ("+p.comm+" nhận xét)<br/>"); }};
//]]>
</script>
//<![CDATA[
// Hot Posts Widget styled by Huynh-nhat-ha.blogspot.com
getHP=function(d){document.write(d)};
hotPost = function(u,t,c,b) { this.url = u; this.tit = t; this.comm = c; this.body = b };
var sortAllPosts=[];
sortAllPostsRecopilation = function (json) {
var total,entry,i,x,arr,lnk,com,ttle;
total = json.feed.entry.length;
for(i=0; i < total; i++){
entry=json.feed.entry[i];
for (x=0; x < entry.link.length; x++){
arr = entry.link[x];
lnk = (arr.rel=="alternate" ? arr.href : lnk);
if(arr.rel=="replies"){
com = (arr.type=="text/html" ? parseInt(arr.title,10) : com);
}
}
ttle = entry.title.$t;
txt = ('summary' in entry ? entry.summary.$t : entry.content.$t);
sortAllPosts.push(new hotPost(lnk,ttle,com,txt));
}
sortAllPosts=sortAllPosts.OrderMaxMin();
};
Array.prototype.OrderMaxMin = function(){
var max=0;
var tmp=[];
var x,i,post;
for(i=0; i<this.length; i++){
post=this[i];
max = ( post.comm > max ? post.comm : max);
}
for(x = max; x>=0; x--){
for(i=0; i<this.length; i++){
post=this[i];
if(post.comm == x){
tmp.push(post);
}
}
}
return(tmp);
};
Array.prototype.DisplayHotPosts = function(max,txt) { for(var i=0; i<max;i++){ p=this[i]; getHP(p.tit.link(p.url)+" ("+p.comm+" nhận xét)<br/>"); }};
//]]>
</script>
Lưu Template.
Bước 2. Vào Page Elements. Trên sidebar thêm một tiện ích HTML/Javascript và đặt đoạn code sau đây vào phần nội dung tiện ích (đặt tên tiện ích là Bài viết Hot hay tên gì đó tùy ý bạn).
<div id='HotPosts'>
<script src='http://huynh-nhat-ha.blogspot.com/feeds/posts/default?alt=json-in-script&callback=sortAllPostsRecopilation&max-results=999' type='text/javascript'></script>
<script type='text/javascript'>sortAllPosts.DisplayHotPosts(7,00);</script>
</div>
<script src='http://huynh-nhat-ha.blogspot.com/feeds/posts/default?alt=json-in-script&callback=sortAllPostsRecopilation&max-results=999' type='text/javascript'></script>
<script type='text/javascript'>sortAllPosts.DisplayHotPosts(7,00);</script>
</div>
Thay huynh-nhat-ha bằng tên blogspot của bạn, thay số 7 để chỉ số bài viết được hiển thị trên tiện ích.
Lưu ý nếu bạn rành về CSS thì có thể định dạng CSS cho tiện ích này theo kiểu như sau.
#HotPosts {
….
}
#HotPosts a {
…
}
";
/* */
….
}
#HotPosts a {
…
}
Tiện ích Bài viết Hot (Hot Posts Widget) là tiện ích hiển thị những bài viết được bạn đọc quan tâm và có nhiều nhận xét nhất. Tiện ích này khác với tiện ích Popular Posts hiển thị những bài viết được xem nhiều nhất.
Script trong thủ thuật sau đây sẽ lọc những bài viết được bình luận nhiều nhất trong blogspot để tạo ra tiện ích mà tôi đặt tên là Hot Posts. Tiện ích này hiển thị tiêu đề bài viết và số nhận xét cho mỗi bài viết. Thiết nghĩ đây cũng là một tiện ích cần thiết cho blogspot, bên cạnh tiện ích Popalar Posts sẵn có của Blogger.
Bạn có thể xem Demo dưới đây.
Để cài đặt tiện ích này, bạn hãy thực hiện như sau.
Bước 1. Đăng nhập Blogger, vào Design >> Edit HTML. Đặt đoạn code bên dưới vào trước thẻ </head>.
Lưu Template.
Bước 2. Vào Page Elements. Trên sidebar thêm một tiện ích HTML/Javascript và đặt đoạn code sau đây vào phần nội dung tiện ích (đặt tên tiện ích là Bài viết Hot hay tên gì đó tùy ý bạn).
Thay huynh-nhat-ha bằng tên blogspot của bạn, thay số 7 để chỉ số bài viết được hiển thị trên tiện ích.
Lưu ý nếu bạn rành về CSS thì có thể định dạng CSS cho tiện ích này theo kiểu như sau.
Script trong thủ thuật sau đây sẽ lọc những bài viết được bình luận nhiều nhất trong blogspot để tạo ra tiện ích mà tôi đặt tên là Hot Posts. Tiện ích này hiển thị tiêu đề bài viết và số nhận xét cho mỗi bài viết. Thiết nghĩ đây cũng là một tiện ích cần thiết cho blogspot, bên cạnh tiện ích Popalar Posts sẵn có của Blogger.
Bạn có thể xem Demo dưới đây.
Bài viết Hot
Để cài đặt tiện ích này, bạn hãy thực hiện như sau.
Bước 1. Đăng nhập Blogger, vào Design >> Edit HTML. Đặt đoạn code bên dưới vào trước thẻ </head>.
<script type='text/javascript'>
//<![CDATA[
// Hot Posts Widget styled by Huynh-nhat-ha.blogspot.com
getHP=function(d){document.write(d)};
hotPost = function(u,t,c,b) { this.url = u; this.tit = t; this.comm = c; this.body = b };
var sortAllPosts=[];
sortAllPostsRecopilation = function (json) {
var total,entry,i,x,arr,lnk,com,ttle;
total = json.feed.entry.length;
for(i=0; i < total; i++){
entry=json.feed.entry[i];
for (x=0; x < entry.link.length; x++){
arr = entry.link[x];
lnk = (arr.rel=="alternate" ? arr.href : lnk);
if(arr.rel=="replies"){
com = (arr.type=="text/html" ? parseInt(arr.title,10) : com);
}
}
ttle = entry.title.$t;
txt = ('summary' in entry ? entry.summary.$t : entry.content.$t);
sortAllPosts.push(new hotPost(lnk,ttle,com,txt));
}
sortAllPosts=sortAllPosts.OrderMaxMin();
};
Array.prototype.OrderMaxMin = function(){
var max=0;
var tmp=[];
var x,i,post;
for(i=0; i<this.length; i++){
post=this[i];
max = ( post.comm > max ? post.comm : max);
}
for(x = max; x>=0; x--){
for(i=0; i<this.length; i++){
post=this[i];
if(post.comm == x){
tmp.push(post);
}
}
}
return(tmp);
};
Array.prototype.DisplayHotPosts = function(max,txt) { for(var i=0; i<max;i++){ p=this[i]; getHP(p.tit.link(p.url)+" ("+p.comm+" nhận xét)<br/>"); }};
//]]>
</script>
//<![CDATA[
// Hot Posts Widget styled by Huynh-nhat-ha.blogspot.com
getHP=function(d){document.write(d)};
hotPost = function(u,t,c,b) { this.url = u; this.tit = t; this.comm = c; this.body = b };
var sortAllPosts=[];
sortAllPostsRecopilation = function (json) {
var total,entry,i,x,arr,lnk,com,ttle;
total = json.feed.entry.length;
for(i=0; i < total; i++){
entry=json.feed.entry[i];
for (x=0; x < entry.link.length; x++){
arr = entry.link[x];
lnk = (arr.rel=="alternate" ? arr.href : lnk);
if(arr.rel=="replies"){
com = (arr.type=="text/html" ? parseInt(arr.title,10) : com);
}
}
ttle = entry.title.$t;
txt = ('summary' in entry ? entry.summary.$t : entry.content.$t);
sortAllPosts.push(new hotPost(lnk,ttle,com,txt));
}
sortAllPosts=sortAllPosts.OrderMaxMin();
};
Array.prototype.OrderMaxMin = function(){
var max=0;
var tmp=[];
var x,i,post;
for(i=0; i<this.length; i++){
post=this[i];
max = ( post.comm > max ? post.comm : max);
}
for(x = max; x>=0; x--){
for(i=0; i<this.length; i++){
post=this[i];
if(post.comm == x){
tmp.push(post);
}
}
}
return(tmp);
};
Array.prototype.DisplayHotPosts = function(max,txt) { for(var i=0; i<max;i++){ p=this[i]; getHP(p.tit.link(p.url)+" ("+p.comm+" nhận xét)<br/>"); }};
//]]>
</script>
Lưu Template.
Bước 2. Vào Page Elements. Trên sidebar thêm một tiện ích HTML/Javascript và đặt đoạn code sau đây vào phần nội dung tiện ích (đặt tên tiện ích là Bài viết Hot hay tên gì đó tùy ý bạn).
<div id='HotPosts'>
<script src='http://huynh-nhat-ha.blogspot.com/feeds/posts/default?alt=json-in-script&callback=sortAllPostsRecopilation&max-results=999' type='text/javascript'></script>
<script type='text/javascript'>sortAllPosts.DisplayHotPosts(7,00);</script>
</div>
<script src='http://huynh-nhat-ha.blogspot.com/feeds/posts/default?alt=json-in-script&callback=sortAllPostsRecopilation&max-results=999' type='text/javascript'></script>
<script type='text/javascript'>sortAllPosts.DisplayHotPosts(7,00);</script>
</div>
Thay huynh-nhat-ha bằng tên blogspot của bạn, thay số 7 để chỉ số bài viết được hiển thị trên tiện ích.
Lưu ý nếu bạn rành về CSS thì có thể định dạng CSS cho tiện ích này theo kiểu như sau.
#HotPosts {
….
}
#HotPosts a {
…
}
….
}
#HotPosts a {
…
}
Bạn đã xem chưa
- Ghép 2 tiện ích Popular Posts với nhau
- Tiện ích Bài đăng phổ biến bố trí chiều ngang
- Tùy biến tiện ích Bài xem nhiều nhất
- Cài đặt bộ chèn Emoticons cho hệ thống nhận xét phân cấp
- Tạo trang homepage riêng cho trang nhãn nhất định
- Tạo Next Post và Previous Post theo phong cách Wordpress
- Tiện ích Bài đăng phổ biến bố trí chiều ngang
- Tiện ích Bài viết mới nhất dành cho đối tác VIP
- Thủ thuật yêu cầu: Script liệt kê và gọi script
- Theo dõi bài viết mới nhất từ blog khác
- Tạo thanh điều hướng bài viết chuẩn cho blogspot
- Tiện ích Nhận xét mới nhất không dùng Javascript
- Bài viết mới nhất cho nhãn không dùng Javascript
- Ẩn nội dung nhận xét của người nhận xét không URL
- Bài viết mới nhất có ảnh đại diện cho từng nhãn
- Tùy biến Bài viết mới nhất có ảnh đại diện không dùng Javascript
- Tiện ích Bài viết mới nhất có ảnh đại diện bản full
- Bài viết mới nhất có ảnh đại diện cho nhiều nhãn nằm ngang
- Tiện ích Bài viết mới nhất có ảnh đại diện
- Tiện ích Bài viết mới nhất có ảnh đại diện đặt cuối bài viết
- Tiện ích Bài viết liên quan ngẫu nhiên có ảnh đại diện
0 nhận xét | Viết lời bình