Home » Thủ thuật blog
Tiện ích hiển thị số bài viết và số bài comment
Thứ Tư, 22 tháng 4, 2009
Thủ thuật này có lẽ không mới lạ gì so với blogger, nên mình sẽ không giới thiệu gì nhiều.
Trước tiên thực hiện thủ thuật này thì blog của bạn phải dược kích họat chức năng RSS Feed từ trước.
Hình minh họa:

Sau đây là cách thực hiện:
1. Tạo 1 Widget HMTL/Javascript
2. Dán đọan code bên dưới vào widget, và di chuyển đến nơi muốn hiển thị, save template lại.
Code:
<script style=”text/javascript”>
function numberOfPosts(json) {
document.write(’Total Posts: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
function numberOfComments(json) {
document.write(’Total Comments: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
</script>
<ul><li><script src=”http://yourblog.blogspot.com/feeds/posts/default?alt=json-in-script&callback=numberOfPosts”></script></li>
<li><script src=”http://yourblog.blogspot.com/feeds/comments/default?alt=json-in-script&callback=numberOfComments”></script></li></ul>
function numberOfPosts(json) {
document.write(’Total Posts: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
function numberOfComments(json) {
document.write(’Total Comments: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
</script>
<ul><li><script src=”http://yourblog.blogspot.com/feeds/posts/default?alt=json-in-script&callback=numberOfPosts”></script></li>
<li><script src=”http://yourblog.blogspot.com/feeds/comments/default?alt=json-in-script&callback=numberOfComments”></script></li></ul>
Chú ý: thay đổi các code màu đỏ thành nhưng link của bạn. Code màu xanh có thể tùy chỉnh theo ý bạn.
Như vậy đã xong.
Nguồn Blog Solid

- Jquery Slider Tin Tức - News Slider
- Quà tặng âm nhạc cho BlogSpot
- Tiện ích Top Commentators cho blogspot
- Chèn link Google Search vào footer của bài viết
- SlideTab Recent posts (jQuery)
- [Update] Tạo Menu Thanh menu ngang có sổ dọc xuống
- Ngẫu hứng Blogger (3)
- Ngẫu hứng Blogger (2)
- Bạn biết gì về Blogspot, hãy chia sẻ cùng tôi.
- Blogger chính thức add avatar vào comment feed
- Thêm Reactions vào bài viết của blogspot
- Share 3 template bloger đẹp cho anh em
Comments[ 0 ]
Đăng nhận xét