Thursday, April 23, 2009

Tiện ích hiển thị số bài viết và số bài comment

[FD's BlOg] - Do yêu cầu test thử trên blog, và một phần mình cũng chưa có lưu trữ thủ thật này trên blog, nên sẵn tiện post 1 bài về tiện ích này.

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>

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
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 nhận xét

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© 2025 Sổ ghi chú
Designed by BlogThietKe Cooperated with Duy Pham
Released under Creative Commons 3.0 CC BY-NC 3.0
Posts RSSComments RSS
Back to top