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
Tăng cỡ chữ
Mặc định
Giảm cỡ chữ
Liên hệ mail: tpm1512@yahoo.com và xem tất cả bài viết trang này
Tại đây
Nhấn vào theo dõi thăm trang web của Trần Phúc Minh
-
https://yogaso1.blogspot.com/2009/04/tien-ich-hien-thi-so-bai-viet-va-so-bai.html?m=0
Minh cám ơn bạn đã quan tâm và rất vui vì bài viết đã đem lại thông tin hữu ích cho bạn.
MENU
Sản phẩm
Trang chủ
Nổi bậc
Tiện ích
Tài khoản
Tác vụ
YOUTUBE
Trang chủ
Lên trên
Tổng số Bình luận [ 0]
Đăng nhận xét