40 Easy Peasy Recent Comments Widget for Blogger Layouts
Monday, August 25, 2008 /

As many bloggers have experienced troubles using the original recent comments widget, I've been researching new methods we could use to add this function to our blogs. To my surprise, I realised that we can alter the code of the default Blogger Feed widget to accomodate our need to display recent comments in the layout. By simply manipulating the code, we can create a widget to display the name and a summary/full content of the 5 most recent comments posted to our blogs!







There are several advantages to using this method:

  • Special characters are more likely to be recognized and correctly displayed

  • This method does not rely on externally hosted scripts, which makes the widget load much faster

  • It is much easier to make alterations to the widget

  • Comments are displayed in list format, and can automatically be styled to match the design of your blog.

So far, I have found only two disadvantages to using this method. Firstly, as this is based on a default feed widget, we can only display a maximum of 5 recent comments (the limitation applied by Blogger). Secondly, there is no way to display the title of the post commented on, as this information is not included in the code of the atom.xml feed.



At present, you would need to edit the contents of your Blogger template to add this new version of the "recent comments" widget due to current problems with Blogger's "Add widget" API. As soon as I am able to access the API successfully, I will work on a widget installer which will enable you to add this new widget with ease.



For now, here are the instructions to add this widget to your template by customizing your blog's HTML code.





How to add the new "Recent Comments" widget to your Blogger layout





Step One: Back up your template!



Firstly, you should make a full back-up of your existing template. This will enable you to restore your template to it's original composition if you accidentally make a mistake.



To make a back-up of your blog template, go to Layout>Edit HTML in your Blogger dashboard, and click the "Download full template" link near the top of the page.



This allows you to save a copy of your template to your computer as an XML file. Rename your template to help you find it easily, being sure to retain the ".xml" extension.





Step Two: Add new code to your template

In this step, we will add a complete widget (including the widget template) by adding HTML code.



For this, you will need to access the Edit HTML page for your Blogger template. Do not click the "Expand widget templates" box as this may make it more difficult for you to see where the code should be added.



Using your browser's search function (CTRL+F or CMD+F) locate the following line of code:

<b:section class="sidebar" id="sidebar" preferred="yes">
If you cannot locate this exact section, find a line which begins with <b:section which references the "class" or "ID" of sidebar.



Immediately after this line, paste this entire section of code:



<b:widget id='Feed99' locked='false' title='Recent Comments' type='Feed'>

<b:includable id='main'>

<h2><data:title/></h2>

<div class='widget-content'>

<ul expr:id='data:widget.instanceId + "_feedItemListDisplay"'>

<b:loop values='data:feedData.items' var='i'>

<li>

<a expr:href='data:i.alternate.href'>

<b:if cond='data:showItemAuthor'>

<b:if cond='data:i.author != ""'>

<span class='item-author'>

<data:i.author/> said:

</span>

</b:if>

</b:if>

<span class='item-title'>

<data:i.title/>

</span>

<b:if cond='data:showItemDate'>

<b:if cond='data:i.str_published != ""'>

<span class='item-date'>

 on <data:i.str_published/>

</span>

</b:if>

</b:if>

</a>

</li>

</b:loop>

</ul>

<b:include name='quickedit'/>

</div>

</b:includable>

</b:widget>

<b:widget id='Feed2' locked='false' title='Recent Posts' type='Feed'>

<b:includable id='main'>

<h2><data:title/></h2>

<div class='widget-content'>

<ul expr:id='data:widget.instanceId + "_feedItemListDisplay"'>

<b:loop values='data:feedData.items' var='i'>

<li>

<span class='item-title'>

<a expr:href='data:i.alternate.href'>

<data:i.title/>

</a>

</span>

<b:if cond='data:showItemDate'>

<b:if cond='data:i.str_published != ""'>

<span class='item-date'>

 - <data:i.str_published/>

</span>

</b:if>

</b:if>

<b:if cond='data:showItemAuthor'>

<b:if cond='data:i.author != ""'>

<span class='item-author'>

 - <data:i.author/>

</span>

</b:if>

</b:if>

</li>

</b:loop>

</ul>

<b:include name='quickedit'/>

</div>

</b:includable>

</b:widget>
Then preview your template. If you have made any errors in pasting this section of code, you will notice the error in your preview, or will receive an error message. If this is the case, click the "Clear Edits" link near the bottom of the page to revert your template back to normal, then begin again.



To offer a better understanding of where to paste the above section of code, here is an annotated screenshot:





Once you have correctly pasted this code, save your template. At first you will not be able to see the recent comments widget appear in your blog layout. We need to add the URL for your comments feed and tweak a few options before the widget will appear.





Step 3: Add Comment Feed URL

The final step to adding this new recent comments widget is to add the Feed URL for your comments feed.



To do this, go to Layout>Page Elements where you should see a new "Recent Comments" feed appear at the top of your sidebar.



Click on the "Edit" link for this widget, where you will be presented with the regular pop-up screen for a Feed Widget:





You need to add the URL of your blog's comment feed in the "Feed URL" box.



The default URL for your blog's comment feed will be something like this:





http://yourblog.blogspot.com/feeds/comments/default


Where "yourblog.blogspot.com" is the URL of your blog. If you use a custom domain, change this to the actual URL of your blog. For example, the URL for the Blogger Buster comments feed is http://www.bloggerbuster.com/feeds/comments/default



You should also tick at least the "Item Sources/Authors" box as this field will be used to display the commenter's name.



Optionally, you could also tick the "Item Dates" option if you would prefer to display the date when comments were added.



Once you have added the URL to your comments feed and ticked the appropriate options, click the "Save" button and take a look at your blog. You should now see your new "recent comments" widget appear in your blog layout.



When this widget is installed, you can move it around to a different part of your layout on the Layout>Page Elements page. As each entry of the comments feed is presented as a list item, the widget should take on the appearance of other list-type widgets in your layout.





Comments? Suggestions?

I hope this new version of the recent comments widget will be suitable for most needs and is easy to install in your Blogger template. Please let me know if you experience any problems when using this widget, or if you have any suggestions for how it may be improved, by leaving your comments below.



Initial photo by Rightee (Flickr Creative Commons).



40 comments:

February 3, 2009 at 9:13 AM Th. said...

.

I added it to my blog today and it works great. Thanks.

February 4, 2009 at 9:35 AM Th. said...

.

Mine isn't updating either. It uploaded the comments once, but never again. I've tried clearing my cache, but it doesn't seem to be my machine.

February 25, 2009 at 8:19 AM David Rudel said...

I just recently installed this widget, and when I go to configure it [by clicking "edit" on the Page Elements screen], the configuration box is blank [with a thin, wide flesh-colored oval]...

March 5, 2009 at 12:26 PM
Anonymous said...

Thank you i have added the code successfully. But when i click on edit, it doesn't give the option to add my blog comment feed. My blog test address is test1953.blogspot.com

March 9, 2009 at 5:47 PM Dura-Foam Solar Center said...

I'm having the same problem--the config box is blank... I simply pasted the code exactly as it is given above--so I don't see what I could have done wrong.

March 12, 2009 at 1:50 PM Aimz said...

You could also add it as a feed and check "Item sources/authors" - less custom styling available, but effective and simple.

April 5, 2009 at 9:44 AM Drew said...

I have the same issue, usually i'm pretty good with this stuff, but like these last few people said when I click on the "Edit" link for the comments in the Layout, it just pops up a bare looking page, with no input form for adding my feed location...

April 20, 2009 at 3:49 AM Asif said...

Thanks for the information.

Infomist Services

April 20, 2009 at 3:15 PM DBSKsleeplessNights2 said...

WOW Thanks a lot..! i'll be using this, My blog extremmely needs things~

April 25, 2009 at 3:12 AM The Peoples Program Team said...

nice idea., cool., thanks for the post dude.,

April 27, 2009 at 3:20 PM Shawnee said...

Our Online Pharmacy no Prescription doctors will evaluate your health information and provide you with a prescription, so you do not need a prescription from your regular family physician to cheap Generic Viagra. More info at: http://www.safemeds.com/

April 27, 2009 at 5:42 PM
Stephanie said...

i found this method to be much easier:

http://www.tipsblogger.com/2009/04/add-recent-comments-widget-to-blogger.html

May 1, 2009 at 12:02 AM billrainier said...

I am really satisfied with my it. I wish I would have thought of it first. Awesome!

May 5, 2009 at 3:44 PM cheapest generic viagra said...

Our order viagra will evaluate your health information and provide you with a prescription, so you do not need a prescription from your regular family physician to cheap Generic Viagra. More info at: http://www.xlpharmacy.com

May 8, 2009 at 2:56 PM
nat said...

mine it say's like this!We were unable to save your template,Please correct the error below and submit your template again.
More than one widget was found with id: Feed2. Widget IDs should be unique.

May 25, 2009 at 8:15 PM chris said...

I have a question Amanda, it seems that I cannot edit the Recent Feed, edit panel appears blank, can you help me with this?
Thanks!

May 28, 2009 at 8:56 AM Justin said...

Great Article! Really helpful!
By the way, take a look at this site: http://www.vismomedia.com and get paid for hosting cool videos in your blogs.

May 31, 2009 at 9:01 PM Pinnacle said...

Great post! Thanks for posting the code for this widget!

June 8, 2009 at 6:22 AM Smitten by Britain said...

I'm having the same trouble where I got into edit the comment feed and blogger gives me essentially a blank box. I can't edit the feed.

Thanks.

July 4, 2009 at 12:22 AM Kamagra Jelly said...

Hi...

Its nice to see that it is a great post ...
I just liked them...
Generic Viagra, Sildenafil Citrate

July 14, 2009 at 2:06 AM James Touso said...

Its really great to read this.My friend Mark always used to read this type of stuff.He is suffering from impotence
nowadays and he is planning about
kamagra,generic viagra,silagra,meltabs,forzest from online
pharmacy like http://www.trustpharma.com for better sexual pleasure.Are these drugs benificial?

July 14, 2009 at 3:54 AM generic viagra pharmacy said...

thanks for sharing this post. intresting thing here.

July 21, 2009 at 10:09 PM Lerman said...

Cialis works the same way as buy cialis canada. Both the drugs enhance blood flow to the groin area. The major point of difference is that viagra professional remains effective for a 36-hour time period,
compared to just four hours with Viagra. In addition, cialis online without prescription can take effect slightly faster than Viagra. They each take effect in up to 30 minutes, give or take a few minutes. The best part about Cialis is that it offers the couple more lexibility.

July 29, 2009 at 8:10 AM us drugstore said...

Good review, thanks.

July 29, 2009 at 12:06 PM chantix said...

We at Chantixonline, are available to you 24X7 and suggest you to keep yourself permanently away from the dangerous addiction of ‘nicotine’ by having regular dosage of worldwide acclaimed Pfizer medicine named “Chantix”. To keep yourself updated about the harm causes by ‘nicotine’ to your body and about the ultimate cure of it, then please login to http://www.chantixonline.com .

July 30, 2009 at 7:05 PM Rumi said...

Nice, Thank you, my friend hafez will be glad of this info.

August 2, 2009 at 3:19 AM generic drugs said...

Thanks, helpful source.

August 5, 2009 at 9:31 AM Fusion said...

Hi Amanda,

I have added you recent widget directly from add gadgets .. didn't follow these steps..

It works fine.. but i have one problem

this is my fake template where i test http://tyroos.blogspot.com i need recent comments to be like twitter updates.. the style.

plzz help me...

August 7, 2009 at 4:38 AM KAMAGRA online said...

thanks for sharing this info...

August 13, 2009 at 1:10 AM Ecommerce said...

Valuable informations. This is a very good guide.

August 20, 2009 at 12:23 AM REAL said...

Nice share....but I got some problems after adding it.....the feed url did not show!! wha can I do?

August 22, 2009 at 3:23 PM My layouts said...

Thanks for the information.

August 24, 2009 at 2:36 AM REAL said...

I found some easy tricks

September 22, 2009 at 8:28 AM Tannia said...

Hi!!
Interesting information, thanks a lot. I would like to know about Online Pharmacy

September 24, 2009 at 7:31 AM Viagra Online said...

really good steps]! totally true
i like this post a lot!!

Katie D. Nuñez

September 8, 2011 at 10:18 PM asterhealthsource said...

Good blog..Actually reading your blog post is my pleasure..very interesting blog created here.
kamagra

Post a Comment