home Twitter RSS feeds

Tutorial: Showing recent comments on blog

Blogged by: Kitty on Thursday, September 20, 2012  
Commentators:
Facebook comments: comments

Today's tutorial will show you two methods of showing recent comments on the blog. Please take note that each one has its own limitation(s) so before copying and pasting the codes into your blog, do read this tutorial carefully.

Method 1


<h2>Recent Comments</h2>
<Blogger>
<MainPage>
<BlogItemCommentsEnabled>
<BlogItemComments>
<$BlogCommentAuthor$> //
<a href="<$BlogCommentPermalinkURL$>">
<$BlogCommentPermalinkURL$></a>
<p class="comment-body">
<$BlogCommentBody$>
</p>
</BlogItemComments>
</BlogItemCommentsEnabled>
</MainPage>
</Blogger>


The codes above will be shown only on the main page and not on individual pages. If you want them to appear on the individual pages as well, remove the <MainPage></MainPage> tags.

However, this code does not show the recent comments per se. It only shows recent comments for the post on the current page.


Method 2

By using this code snippet, recent comments will only be visible if the blog is set to public. The reason for this is because the script utilises the blog feeds in order to generate the recent comment. The script needs to be able to read the feed and it can't read the feed if the blog is put on private.


<script type="text/javascript">
function showrecentcomments(json){for(var i=0;i<a_rc;i++){var b_rc=json.feed.entry[i];var c_rc;if(i==json.feed.entry.length)break;for(var k=0;k<b_rc.link.length;k++){if(b_rc.link[k].rel=='alternate'){c_rc=b_rc.link[k].href;break;}}c_rc=c_rc.replace("#", "#comment-");var d_rc=c_rc.split("#");d_rc=d_rc[0];var e_rc=d_rc.split("/");e_rc=e_rc[5];e_rc=e_rc.split(".html");e_rc=e_rc[0];var f_rc=e_rc.replace(/-/g, " ");f_rc=f_rc.link(d_rc);var g_rc=b_rc.published.$t;var h_rc=g_rc.substring(0, 4);var i_rc=g_rc.substring(5, 7);var j_rc=g_rc.substring(8, 10);var k_rc=new Array();k_rc[1]="Jan";k_rc[2]="Feb";k_rc[3]="Mar";k_rc[4]="Apr";k_rc[5]="May";k_rc[6]="Jun";k_rc[7]="Jul";k_rc[8]="Aug";k_rc[9]="Sep";k_rc[10]="Oct";k_rc[11]="Nov";k_rc[12]="Dec";if("content" in b_rc){var l_rc=b_rc.content.$t;}else if("summary" in b_rc){var l_rc=b_rc.summary.$t;}else var l_rc="";var re=/<S[^>]*>/g;l_rc=l_rc.replace(re, "");if(m_rc==true)document.write('On '+k_rc[parseInt(i_rc, 10)]+' '+j_rc+' ');document.write('<a href="'+c_rc+'">'+b_rc.author[0].name.$t+'</a> commented');if(n_rc==true)document.write(' on '+f_rc);document.write(': ');if(l_rc.length<o_rc){document.write('<i>&#8220;');document.write(l_rc);document.write('&#8221;</i><br/><br/>');}else{document.write('<i>&#8220;');l_rc=l_rc.substring(0, o_rc);var p_rc=l_rc.lastIndexOf(" ");l_rc=l_rc.substring(0, p_rc);document.write(l_rc+'&hellip;&#8221;</i>');document.write('<br/><br/>');}}document.write('<div style="font-size:70%;text-align:center"></div>');}
</script>

<script style='text/javascript'>var a_rc=3;var m_rc=true;var n_rc=true;var o_rc=100;</script><script src='http://www.yourblogname.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments'></script>


Change the values in the code above.

var a_rc = 3 // this is the number of comments you want to display

var o _rc = 100 // this is the length of the comments you want to display

yourblogname.blogspot.com // change it to your own blog URL

Labels: ,


Comments to Tutorial: Showing recent comments on blog:


Post a Comment

Commenting policy:
1. Please leave comments that are relevant to the blog post.
2. Comments on posts that are more than 14 days old will be moderated.
3. Do not post advertisements to your own site/products here.
4. Do not post private information, it will be deleted.
5. Refrain from using abusive/vulgar words, if you have personal issues with me, contact me directly through the contact form or my email instead.

Facebook comments to Tutorial: Showing recent comments on blog:


Tutorial: Showing recent comments on blog

Blogged by: Kitty on Thursday, September 20, 2012  
Commentators:
Facebook comments: comments

Today's tutorial will show you two methods of showing recent comments on the blog. Please take note that each one has its own limitation(s) so before copying and pasting the codes into your blog, do read this tutorial carefully.

Method 1


<h2>Recent Comments</h2>
<Blogger>
<MainPage>
<BlogItemCommentsEnabled>
<BlogItemComments>
<$BlogCommentAuthor$> //
<a href="<$BlogCommentPermalinkURL$>">
<$BlogCommentPermalinkURL$></a>
<p class="comment-body">
<$BlogCommentBody$>
</p>
</BlogItemComments>
</BlogItemCommentsEnabled>
</MainPage>
</Blogger>


The codes above will be shown only on the main page and not on individual pages. If you want them to appear on the individual pages as well, remove the <MainPage></MainPage> tags.

However, this code does not show the recent comments per se. It only shows recent comments for the post on the current page.


Method 2

By using this code snippet, recent comments will only be visible if the blog is set to public. The reason for this is because the script utilises the blog feeds in order to generate the recent comment. The script needs to be able to read the feed and it can't read the feed if the blog is put on private.


<script type="text/javascript">
function showrecentcomments(json){for(var i=0;i<a_rc;i++){var b_rc=json.feed.entry[i];var c_rc;if(i==json.feed.entry.length)break;for(var k=0;k<b_rc.link.length;k++){if(b_rc.link[k].rel=='alternate'){c_rc=b_rc.link[k].href;break;}}c_rc=c_rc.replace("#", "#comment-");var d_rc=c_rc.split("#");d_rc=d_rc[0];var e_rc=d_rc.split("/");e_rc=e_rc[5];e_rc=e_rc.split(".html");e_rc=e_rc[0];var f_rc=e_rc.replace(/-/g, " ");f_rc=f_rc.link(d_rc);var g_rc=b_rc.published.$t;var h_rc=g_rc.substring(0, 4);var i_rc=g_rc.substring(5, 7);var j_rc=g_rc.substring(8, 10);var k_rc=new Array();k_rc[1]="Jan";k_rc[2]="Feb";k_rc[3]="Mar";k_rc[4]="Apr";k_rc[5]="May";k_rc[6]="Jun";k_rc[7]="Jul";k_rc[8]="Aug";k_rc[9]="Sep";k_rc[10]="Oct";k_rc[11]="Nov";k_rc[12]="Dec";if("content" in b_rc){var l_rc=b_rc.content.$t;}else if("summary" in b_rc){var l_rc=b_rc.summary.$t;}else var l_rc="";var re=/<S[^>]*>/g;l_rc=l_rc.replace(re, "");if(m_rc==true)document.write('On '+k_rc[parseInt(i_rc, 10)]+' '+j_rc+' ');document.write('<a href="'+c_rc+'">'+b_rc.author[0].name.$t+'</a> commented');if(n_rc==true)document.write(' on '+f_rc);document.write(': ');if(l_rc.length<o_rc){document.write('<i>&#8220;');document.write(l_rc);document.write('&#8221;</i><br/><br/>');}else{document.write('<i>&#8220;');l_rc=l_rc.substring(0, o_rc);var p_rc=l_rc.lastIndexOf(" ");l_rc=l_rc.substring(0, p_rc);document.write(l_rc+'&hellip;&#8221;</i>');document.write('<br/><br/>');}}document.write('<div style="font-size:70%;text-align:center"></div>');}
</script>

<script style='text/javascript'>var a_rc=3;var m_rc=true;var n_rc=true;var o_rc=100;</script><script src='http://www.yourblogname.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments'></script>


Change the values in the code above.

var a_rc = 3 // this is the number of comments you want to display

var o _rc = 100 // this is the length of the comments you want to display

yourblogname.blogspot.com // change it to your own blog URL

Labels: ,



Comments to Tutorial: Showing recent comments on blog:


Post a Comment

Commenting policy:
1. Please leave comments that are relevant to the blog post.
2. Comments on posts that are more than 14 days old will be moderated.
3. Do not post advertisements to your own site/products here.
4. Do not post private information, it will be deleted.
5. Refrain from using abusive/vulgar words, if you have personal issues with me, contact me directly through the contact form or my email instead.

Facebook comments to Tutorial: Showing recent comments on blog:


Hire me to design your blog!

I offer designing and re-designing of Classic Blogger templates. Examples of my design can be found on my portfolio website.

The basic rate for a design starts from $25 USD. The rate is based on the complexity of the design. The more elaborate the design is, the higher the price is.

How to place your order

Send me an email via the contact form and state clearly how you want your design to be. This includes colour scheme, layout (with or without sidebar, number of columns, etc), any extra features, etc.

Your email should be in this format:
Name:
Design: Please give detailed explanation on how you want your template to look like
Preferred payment method: Paypal/Moneybookers/Payza/Bank transfer to Baiduri bank

I shall respond to your email within 3 (three) days. Your order will be placed into a Waiting Queue as orders are processed on a first come, first serve basis.

Payment methods

Payment has to be made to either by PayPal, or Moneybookers.

However, if you choose to pay via (international) bank transfer, be aware that you may be charged for the transfer service.

Other important information

Throughout the designing process, I may need to refer back to you for questions/opinions so do check your email frequently. This is to ensure the design can be done as soon as possible.

Depending on the design, your template make take up to over 1 (one) week to finish. You will be informed once the template is done.

I will send you an email requesting for the payment after the template is done. Once the payment is received, I will email you the complete template along with the necessary files.

All of my designs/templates will come with a credit section. This section must be left intact and you may not remove nor alter them. Resources that come with the designs/templates may not be redistributed or reproduced.

The designer

Kitty

Kitty. 29. Blogger, web design hobbyist, compulsive shopper and bibliophile based in Brunei. Enjoys creating and designing websites, dabbling with HTML, CSS and PHP.

I've been blogging since 2005 (or earlier) though my experience with the internet started back in 2000. My main interest is in web design and development. Other times you can see me wrapped around a book or glued to Astronomy and web design magazines.

The website

This website was created in January 2011 and the domain was purchased by me in late December 2010. Initially the website was intended to house tutorials for Classic Blogger/Blogspot only however over the time it has developed into what you see today.

Several of the tutorials and articles can also be found on Nekonette.com, which is the my main website where I mostly blog about my personal life. Also some of the tutorials here have been moved to that website.

Categories/Labels

Past layouts

These are the layouts that have been used on Codeislove.net previously.

Wooden board

Layout #1

Dark chic

Layout #2

Royal crimson

Layout #3

Articles, Tutorials and Contests

Articles


Please do not copy the articles verbatim and/or redistribute them on your site. And I'd appreciate it if you link back to me.

Tutorials


Please do not copy the tutorials verbatim and/or redistribute them on your site. And I'd appreciate it if you link back to me.

Popular tutorials:

Converting HTML layout to Wordpress series: How to code Classic Blogger template series:

Other tutorials:

Contests

Linkages

On-site navigation

Network

Looking for money-making opportunities? Check out these websites.

Blog Advertising - Advertise on blogs with SponsoredReviews.com

Business 2 Blogger

banner

Contact the webmistress

You can email me your messages/tutorial requests using the contact form:

Advertising

Codeislove: Geek Is Chic is a blog which houses various articles, tips and tutorials on web design as well as a mix of personal insights published by the website owner.

Simple site statistics:
Monthly Unique Visitors: 5000+
Monthly page views: 7,000 ~ 9,000

Also, if you think that you have a good advertisement offer to discuss with me, do contact me and let's discuss about it.

Get reviewed

You can have your website/blog reviewed here on Codeislove. Alternatively, you can also apply to get your website/blog reviewed on my other website, Amalina.org. You can request your review to be public or private. If you choose to have it public, it will be posted here on Codeislove. Similarly, if you want it to be private, I will send the review to you via email.

Please send an email to me in this format and I will get back to you as soon as I can:

Name:
Email:
Website/blog:
Do you want the review to be public/private?

Websites/blogs currently being reviewed:
Aroha - Ashleenah
Twinkle Toes - Eryn - completed
Gadis bermata cokelat - Nurul Nabila - completed

Related Posts Plugin for WordPress, Blogger...