September 25, 2006

Displaying recent comments in sidebar

UPDATE: I came up with a customizable version of Recent comments widget later. Please try it instead of this.

The much-awaited comments feed is completely functional now! I saw Hoctro's post on this topic and found my blog's comments feed also working great. Blogger team seems to have fixed the stale comments issue on Friday. It's very easy to show recent comments in sidebar now (as I have done in my widebar - the wide sidebar). Just goto Page Elements tab, add a page element of type Feed to sidebar and give the following as the Feed URL.
http://yourblogname.blogspot.com/feeds/comments/default. You could select to show the date and comment author if you want.

Notice that they have changed the feed URL not to contain any blog ID etc. This makes it easy to play with any blog's post and comment feed URL programmatically.

UPDATE: Many readers asked me why comments are not immediately shown after published. It is because it takes some time for the new comments to be added to the comment feed. Just wait for some time and it will show up. Yes, this is a limitation of using feed to show recent comments.

60 comments:

  1. Hi Ramani - one thing I'd like to do is have more than 5 comments in my recent comments feed displayed in my sidebar. Do you know how this can be done?

    ReplyDelete
  2. will this work in non beta? how?

    ReplyDelete
  3. Living in canberra, Blogger allows only upto 5 items from the feed. But you could some other service like rss-to-javascript.com if you like more flexibility.

    chllout_lev, no, this approach won't work in non-beta blogs because Blogger doesn't provide comment feed for them. But there are some hacks to do this like this one.

    http://www.editthis.info/bloggerhacks/Farrago_Recent_Comments_Hack

    ReplyDelete
  4. Yes, it's works in Beta.
    But not in a private blog.

    It isn't the solotion.

    And Farrago's don't works in Beta.

    Luis

    ReplyDelete
  5. Luis, I don't understand why comment feed doesn't work in private blogs. You could report to Blogger support.

    ReplyDelete
  6. I'd like to keep the header for this feature the same size, but make the actual text a size or two smaller.

    Is there any way I can do that?

    ReplyDelete
  7. point23,

    we cannot tweak the feed element much. you will have to change the CSS if you want to do all that.

    ReplyDelete
  8. This is or should I say "should be" a VERY simple operation BUT, it telling me I am inputting an url that is not valid. This should work as a feed url...

    http://lincolncountykentucky.blogspot.com/feeds/comments/full

    But it's tellin me it's bad. Could it be because I use HaloScan?

    ReplyDelete
  9. Gary, haloscan comments will not work with this. This is only for Blogger comments.

    ReplyDelete
  10. You know that makes too much sense, I should have known. Using HaloScan take's blogspot's comments out of play.

    Oh well, I'm learning a lot from you guys.

    ReplyDelete
  11. I have applied this to my site. Very kewl!

    ReplyDelete
  12. Hi..
    I would like to know if it would be possible to retrive the names of those who have commented to the blog and dispaly their names in the main-page sidebar.
    So as to say.. if a person is commenting (on a certain post) for the first time then as soon as his comment is posted-his name appears on the "guestlist"
    IF the person is a repeated visitor then the name is dispalyed only once
    That way one can keep track of those who have commented
    I dont know if this is possible..just an enquiry (suggestion)
    Thank you

    ReplyDelete
  13. Hi,

    I don't understand how to use it, I don't have a "page element tab" on Blogger. The only way I know to change the template is to change the html directly. That way, how can I display the comment RSS feed ?

    Thx for your help

    ReplyDelete
  14. Hi! I just added your information for the comments. The newest comments are not showing up. Did I do something wrong?

    ReplyDelete
  15. matthieu, did you switch to Blogger Beta? If so, you should be having the Page elements tab under the Template tab.

    debra, new comments will take some time to show up because the feed gets updated a bit late.

    ReplyDelete
  16. Helpful site. Thanks Ramani.

    ReplyDelete
  17. Hi Ramani,

    I don't know why I keep receiving the message "Invalid Feed URL" at the box element. I tryed the adress and it works, it is:
    http://pruebas-marcelo.blogspot.com/feeds/comments/full

    Do you have any idea what it could be?

    ReplyDelete
  18. Marcelo, I don't see why it's giving you that error. check with Blogger support.

    ReplyDelete
  19. It worked until last monday, today (sat 14th) it keeps giving errors. Can the service be down?

    ReplyDelete
  20. people commented in my blog but they doesn't show on my recent comments. i have already inserted the feed in my beta layout. what's the prob?

    ReplyDelete
  21. gar, please read the update that I added to this post for an explanation.

    ReplyDelete
  22. don't know why I keep receiving the message "Invalid Feed URL"

    ReplyDelete
  23. Your update doesn't cover all problems. I have waited three weeks for my comments to 'update' and they have not. I have left them, but they look silly.

    ReplyDelete
  24. Honeycakes, I can't control the feed. Your feed seems to have some problem. Report to Blogger.

    Ameet, yours too.

    ReplyDelete
  25. Thank you ramani, it works fine for me.

    ReplyDelete
  26. Ramani,

    The comment section is fine but its not picking up the new comments whenever I receive a new comment.

    ReplyDelete
  27. Yes, Priya. Read the Update in this post. It will take some time to be added to the feed.

    ReplyDelete
  28. Try this Marcelo.

    http://pruebas-marcelo.blogspot.com/feeds/comments/default

    ReplyDelete
  29. Thanks Anon! That did the trick. I was getting the "invalid feed" message but then used http://yourname.blogspot.com/feeds/comments/ which solved it! Thanks for that. Not sure why "full" wasn't working ...

    ReplyDelete
  30. Juan, i'm glad to see useful interaction happening in my comments section.

    ReplyDelete
  31. If you're having trouble with the built in comments feed on Blogger Beta (whether it is a speed issue or something else), there are about 100 blogs now using the Blogger Recent Comments module from Storago, and it works painlessly to get them in the sidebar AND an atom feed. Hope this helps.

    ReplyDelete
  32. Hi Ramani! Thank You for Your hint about using Blogger beta self feed.
    Would it be possible just to change the order of the comments fields? like for example: author, post title, date, comment text?

    ReplyDelete
  33. it works. I tried in on my page already: yessssssss....its beautiful updated

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

    ReplyDelete
  34. hey man i was actually interested in such a thing to display comments.. and i went thru some blog and saw haloscan and some other site links.. but thanks for actually givin a blogger hack .. beats going thru another provider .. this is awesome .. ive just set it up in my blog ..have a peek http://netskool.blogspot.com

    ReplyDelete
  35. hi,

    your "Recent Comments" is much neater than the one that comes default, are you using some special javascript to parse it?

    with the feed provided by blogspot, i also noticed that there seems to be a programatic error such that "comment-" will always be left out in the url to the comments. any idea?

    ReplyDelete
  36. Eiklin,

    I have announced newer version of recent comments (that I am using) in this post.

    http://hackosphere.blogspot.com/2006/11/hans-customizes-recent-comments-further.html

    It has the comment URL fixed as well.

    ReplyDelete
  37. thanx Ramani.

    i had made customisation myself -http://eiklin.blogspot.com

    1. the actual javascript is embedded in a new javascript page element. i thought this is a good way so that we need not link to external url (which you have also mentioned) and also the javascript will not be lost whenever we change theme. this works quite well as the javascript page element is "hidden" since there is no actual text to display on the blog.

    2. i have changed the url to be on the comments summary rather than the name of the person making the comment; i guess this made more sense. also, too bad we cannot retrieve the profile of the person making the comment from the comment feed, else one could have created a link for that as well.

    cheers!

    ReplyDelete
  38. Now, more that two months after this post, I have tried several versions for Recent Comments and I like this one best. It places the dates properly in other languages, the comments are too close to each other but we can add a line break, the others put the titles in lower case. We can do almost everything as with the others and without pub. It has a drawback, however, it does not show the titles. Ramani always has the best ideas and finds the best solutions.

    ReplyDelete
  39. I want to allow readers to post comments directly on the sidebar. Can I do that?

    ReplyDelete
  40. What you are asking is similar to inline comment form in post pages. I won't encourage it because it is not safe. Blogger's comment posting page uses secure HTTP whereas your post page does not. If the Google username/password(that you give while posting a comment) are stolen, somebody might access your email etc. This is why Blogger folks have wisely used secure HTTP in Beta.

    ReplyDelete
  41. Thanks ramani!

    But is there a way I can put a link to a separate inline comment form on the sidebar, so people can comment on the entire site in general, or as a way to send me messages.

    Sort of like having just one post on the side bar with a comment link below it.
    Is it possible?

    Thanks! I love your site and looooveee your expandable buttons, it's like magic.

    ReplyDelete
  42. hy, even then you are going to use Blogger's commenting system, right? If you ask the reader to provide his Google credentials in your sidebar, it is not secure. If you allow anonymous comments, it is probably ok.

    ReplyDelete
  43. oh ic! I'll forget it then. Thanks!

    ReplyDelete
  44. My comments using the widget rss will not work - why is that?

    ReplyDelete
  45. Hi. I would like to know how I can change the Header of my Beta Blogger site, and how to put the most commented post on my side bar...

    Thanks... Great blog that you have here...

    bellasvenezolanas@yahoo.com

    ReplyDelete
  46. This is soooo great:) Thanks!!!:)

    ReplyDelete
  47. Pasted the URL feed into the sidebar element. Uploaded comments great. Now, days later after more comments have been left, the sidebar shows the older comments. What gives?

    ReplyDelete
  48. Humblepie,

    There's a bug in Blogger that have been introduced recently which causes old comments to be shown. I hope they will fix them quickly (they know about it).

    ReplyDelete
  49. I hope so, too. Thanks for the info!

    ReplyDelete
  50. Hii Ramani,
    I applied your hack on my blog(http://visitformoney.blogspot.com), plz check how it is ?

    Thanks
    Eliena Andrews
    http://visitformoney.blogspot.com

    ReplyDelete
  51. I keep learning from your advice, but somehow I missed the following if you ever gave that:

    How to list comments in reverse chronological order, ie the most recent one on top?

    Manoj

    ReplyDelete
  52. Manoj, I implemented that feature as part of Neo template. I am not offering the template right now.

    ReplyDelete
  53. Ramani,
    How did you customize your recent comments to say "On April 14, Ramani said".....?
    I'd like to add the date to my recent comments.
    thanks,

    ReplyDelete
  54. Steve, Beautiful Beta's version of recent comments has the date. you can try it.

    ReplyDelete
  55. This isn't directly related, but how did you get a Feedburner feed for all your blogspot comments? Searching on feedburner forums, they don't seem to offer that.

    ReplyDelete
  56. Replicant,

    Just provide the following feed URL to feedburner and create one.

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

    You have to replace "yourblog" with your blog's address.

    ReplyDelete
  57. hi ramani!

    what about for old blogger templates? all i have is a recent comments list that only displays the author and the date/time. i want one that includes the blog item title as well.

    please help! thanks!

    ReplyDelete
  58. sushi, I am not planning to create any more new hacks.

    ReplyDelete
  59. Hi Ramani,
    I would like to know how to reverse the comment list in order the latest comment appeared first of ended post and the oldest one at the bottom ?.

    I mean that like this blog, the latest comments becoming first and the other comment posts sort by the date of the comments in decreasing order...

    Can You explain how i can do that? Pls help.. and thanks..

    ReplyDelete

Dear Visitor,

All the hacks in this blog are proven to work. If some hack doesn't work for you, please re-read the instructions carefully and re-check the code.

-Ramani