Monday, August 17, 2009

ADD RECENT COMMENTS WIDGETS IN BLOG


Simple ways to add “Recent Comments” widget in your Blogger( blogspot) Blog

Two readers( our followers), one from Malaysia and other from United States of America, ask us about any ways to add Recent Comments in their blog. We were very happy to answer them through this post.

Benefits of  adding a “Recent Comments” widget

Before blogging, serious bloggers should know the power of comments. A sincere comment with a link back to a website or blog will definitely noticed by Search Engines. Such valuable links will help to boost  your Page Rank also. So Always remember the “Power of Comments” and  try to give some value comments whenever you visit a blog.

This widget will help the Search engines to crawl easily through the Comments and the Commenting blogs and commented post will get much higher appreciation from crawl robots.

This widget will display 5 recent comments from your posts with date, full structure of comment and title of the post.

This will help readers to know what others feel about your blog and your posts. If you usually receive good comments, then installing this Widget is an excellent way of announcing that to all.

The more comments you receive, then you will get more readers as reader psychology is to read what others read.

All blogger blogs, please follow all steps carefully:

Step A:

Log in to your “DASHBOARD’. Then click on “LAYOUT” and then go to “PAGE ELEMENTS”

Step B:

Now Click on “Add a Gadget”. This will reach a page where you can select many widgets. Select “HTML/JavaScript”. After selecting this you will get an Empty widget box where you had to paste the below given HTML. Don’t close or logout. Stay cool and do what we describe in Step C. Before pasting, give a Title “ Recent Comment Box”

Step C:

Now select and copy the whole code given below( given in Red colors) and paste it in the widget box you have just opened in Step B.

<script style="text/javascript">
function showrecentcomments(json) {
  var numcomments = 5;
  var showcommentdate = true;
  var showposttitle = true;
  var numchars = 100;
for (var i = 0; i < numcomments; i++) {
  var entry = json.feed.entry[i];
  var alturl;
  if (i == json.feed.entry.length) break;
for (var k = 0; k < entry.link.length; k++) {
  if (entry.link[k].rel == 'alternate') {
  alturl = entry.link[k].href;
  break;
  }
  }
  alturl = alturl.replace("#", "#comment-");
  var postlink = alturl.split("#");
  postlink = postlink[0];
  var linktext = postlink.split("/");
  linktext = linktext[5];
  linktext = linktext.split(".html");
  linktext = linktext[0];
  var posttitle = linktext.replace(/-/g," ");
  posttitle = posttitle.link(postlink);
  var commentdate = entry.published.$t;
  var cdyear = commentdate.substring(0,4);
  var cdmonth = commentdate.substring(5,7);
  var cdday = commentdate.substring(8,10);
  var monthnames = new Array();
  monthnames[1] = "Jan";
  monthnames[2] = "Feb";
  monthnames[3] = "Mar";
  monthnames[4] = "Apr";
  monthnames[5] = "May";
  monthnames[6] = "Jun";
  monthnames[7] = "Jul";
  monthnames[8] = "Aug";
  monthnames[9] = "Sep";
  monthnames[10] = "Oct";
  monthnames[11] = "Nov";
  monthnames[12] = "Dec";
  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('<br/>');
  if (showcommentdate == true) document.write('On ' + monthnames[parseInt(cdmonth,10)] + ' ' + cdday + ' ');
document.write('<a href="' + alturl + '">' + entry.author[0].name.$t + '</a> commented');
  if (showposttitle == true) document.write(' on ' + posttitle);
document.write('<br/>');
if (comment.length < numchars) {
document.write('<i>');
  document.write(comment);
document.write('</i>');}
  else
  {
document.write('<i>');
  comment = comment.substring(0, numchars);
  var quoteEnd = comment.lastIndexOf(" ");
  comment = comment.substring(0, quoteEnd);
document.write(comment + '...<a href="' + alturl + '">(more)</a>');
document.write('</i>');}
document.write('<br/>');
  }
document.write('<br/>');
}
</script>
<script src="http://yourblogname.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments"><!—Recent Comment Box generated by http://businessvartha.blogspot.com --></script><a href="http://businessvartha.blogspot.com/2009/05/add-recent-comments-widgets-in-blog.html">Get This Recent Comment Widget!</a>

Very important :

  • Replace "http://yourblogname.blogspot.com ( given in black bold letters) with your blogspot URL. Do not try to change anything from the code

  • Copy all the script given in RED colors

Step D:

Now  Save and if you need to rearrange the position of that widget, then Click,hold the mouse button and move to your desired place in “Layout”. Now again “ Save Template”

Step E:

Reload or refresh your blog and see the new widget. Now the most important step, after installation, comment on this post and drop your blog address.  We will check how the new widget help the spider crawl by search engines.

0 comments:

Post a Comment

 

Easy Tutorial's | Copyright 2009 Tüm Haklar? Sakl?d?r | Blogger Templates by GoogleBoy