2.14.2009

How to Make Recent Comment

. 2.14.2009

Today Tutorial Blog dan Blogger Hack. Comment always make blogger happy , when your blog full of comment from visitor your will get full spirit to get more inspiration to getting better.

We needs to know when a new comment added, so recent comment is important for our blog. Every single comment will appears in tthe recent comment. You know that to adding recent comment can be make by twio ways first by RSS Feeds and another one by Javascript code.

In Tutorial blog today we will make Recent comment with Javascript code,

Let’s make it simple and quick step only:

  1. Go to your Layout
  2. Add a Gadget
  3. Choose HTML/Javascript
  4. Copy-paste code below 

<ul><script style="text/javascript">
function showrecentcomments(json) {
for (var i = 0; i < 5; 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(' on ' + pttitle);
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 href="' + ctlink + '">(more)</a>');
}
}
document.write('</li>');
document.write('<div style="font-size:75&percnt;;text-align:center"><a href="http://blogtutormaster.blogspot.com/2009/02/How-to-make-recent-comment.html">Get this Widget</a></div>');
}
</script>
<script src="http://Yourblogname.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments">
</script></ul>
<noscript>You need to enable JavaScript to read this.</noscript>

 

  5. Save and done

 

Note:

Change URL http://YourBlogname.blogspot.com with your blog URL

 

Now, you have a recent comment widget on your blog, everysingle comment update will show on it.

Thats Tutorial blog today,see you next time

Have a nice try

Enter your email To get Update this blog for free:

Delivered by FeedBurner

Related Posts by Categories




Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

1 comments:

jirin said...

hahaha... ini baru info...

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment

 

BlogRoll

Followers

Master Blog is proudly powered by Blogger.com | Template by o-om.com