Hướng dẫn tạo widget “Recent comment" – Nhận xét mới


Sau mỗi bài viết, khi khách truy cập vào có thể để lại lời nhận xét về bài viết hay những vấn đề thắc mắc đó. Nếu luôn phải tìm những lời nhận xét "Comments" đó thì thật vất vả. Do đó phattrienso đã cố gắng tìm kiếm và phổ biến cho các bạn thủ thuật này.
Trong bài viết trước: "Hướng dẫn thủ thuật tạo Nhận xét mới" có thể là hữu ích tuy nhiên có vể phức tạp và rối rắm.
Trong bài viết này xin hướng dẫn bạn tạo Widget “Nhận xét mới” được tham khảo (thực ra là upload lại) từ http://www.howit.org
Để thực hiện điều này bạn hãy coppy đoạn code dưới và cho vào Widget "HTML/Javascrip" đặt bất cứ đâu trên blog:
<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://tricks-for-blog.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments">
</script></ul>
Trong đó bạn hãy đổi dòng sau đánh dấu màu đỏ thành tên blog của bạn.

5 comments:

Anonymous said...

This post arrived a well-timed ! I can't believe it. I had been searching online for Email Templates. You did a great job and yes i totally agree that your template can make or break your online business. Well Done!

Have a look at my weblog: Beautifulemails.Com

Anonymous said...

you are in point of fact a excellent webmaster.
The site loading pace is incredible. It sort of feels that you are doing any unique trick.
Also, The contents are masterwork. you have performed a wonderful process on
this subject!

my web-site: email Marketing templates

Anonymous said...

Hi there, i read your blog occasionally and i own
a similar one and i was just curious if you get a lot of spam remarks?
If so how do you prevent it, any plugin or anything you can advise?
I get so much lately it's driving me mad so any help is very much appreciated.

my blog post; holiday email templates

Anonymous said...

Hello there! I know this is kinda off topic but I was wondering if you knew where I could
locate a captcha plugin for my comment form?
I'm using the same blog platform as yours and I'm having difficulty finding one?
Thanks a lot!

My website wool sweaters

Anonymous said...

I'm really inspired along with your writing skills and also with the structure for your weblog. Is that this a paid theme or did you customize it your self? Either way keep up the nice high quality writing, it's uncommon to peer a great blog like this one these days.
.

my web page; angry

Post a Comment