23 thg 3, 2011

Tạo Recent comments cho blogspot

2 nhận xét

Tiện ích “Recent Comments – Các nhận xét gần nhất”  hiển thị các nhận xét mới đăng tải trên blog của bạn. Có nhiều cách thực hiện, bạn có thể Add gadget và chọn tiện ích Recent comments do Blogspot hỗ trợ sẵn nhưng cách đó có vẻ như không được thẩm mỹ cho lắm. Vì vậy, mình xin giới thiệu với các bạn thêm một cách rất dễ dàng để tạo ra tiện ích này chỉ bằng một đoạn code.(Nguồn: HowIT)
Các bước thực hiện:
1. Vào Blogger  > Layout  >  Page Elements  Add a Gadget
để thêm Gadget tại vị trí bạn muốn đặt tiện ích “Recent Comments”.

2. Chọn Gadget “HTML/Javascript” và dán đoạn code sau vào đó:
<ul><script style="text/javascript">
function showrecentcomments(json) {
for (var i = 0; i < 10; i++) {
var entry = json.feed.entry[i];
var ctlink;
if (i == json.feed.entry.length) break;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
ctlink = entry.link[k].href;
break;
}
}
ctlink = ctlink.replace("#", "#comment-");
var ptlink = ctlink.split("#");
ptlink = ptlink[0];
var txtlink = ptlink.split("/");
txtlink = txtlink[5];
txtlink = txtlink.split(".html");
txtlink = txtlink[0];
var pttitle = txtlink.replace(/-/g," ");
pttitle = pttitle.link(ptlink);
if ("content" in entry) {
var comment = entry.content.$t;}
else
if ("summary" in entry) {
var comment = entry.summary.$t;}
else var comment = "";
var re = /<\S[^>]*>>/g;
comment = comment.replace(re, "");
document.write('<li>');
document.write('<a href="' + ctlink + '">' + entry.author[0].name.$t + '</a>');
document.write('<br/>');
if (comment.length < 100) {
document.write(comment);
}
else
{
comment = comment.substring(0, 100);
var quoteEnd = comment.lastIndexOf(" ");
comment = comment.substring(0, quoteEnd);
document.write(comment + '...<a target="_blank" href="' + ctlink + '">[[Đọc tiếp]]</a>');
}
}
document.write('</li>');
}
</script>
<script src="http://sodalat.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments">
</script></ul>
Bạn chỉ cần thay đổi dòng chữ sodalat.blogspot.com thành địa chỉ blog của bạn là xong.

Số lượng comment có thể tùy biến được bằng cách thay đổi số 10 (số lượng comment hiển thị) trên đoạn code.

Thất Tình.Biz | Phần mềm | Tin tức | Thủ Thuật | Phim | Game|Teen Sock| Scandan

2 nhận xét:

  • lúc 00:27 19 tháng 7, 2022

    Thank you for sharing this type of information its very helpful – please look this one also
    The Kohi Click Testcounts how many buttons are clicked per second on your mouse. Almost every click test is similar, but one significant difference is that this test is only available on the Minecraft CPS server. This server is known as Kohi, and it is popular for games that require hardcore fractions.

  • lúc 09:10 13 tháng 3, 2025

    Thanks for sharing such information- you can also look this information
    Create a vibrant and artistic backsplash withModern custom chandeliers . The choice of this unique chandeliers design idea adds a burst of colour and personality to the aura of your room. It creates a cozy and intimate atmosphere that turns your room into a luxurious retreat. The offered lighting choice for home interior adds a touch of romance as well as sophistication to your bedroom. Besides, the offered chandeliers enhance the overall ambience with a subtle, customizable glow.

Đăng nhận xét