« This is really interesting… | Main | Coming This Week in TypePad Hacks… »

John T. Unger

How to Make Following the Conversation Easy with a Comments Feed

John T. Unger March 18, 2006

Update 4.10.06: The instructions have been fixed and updated so that you can now easily create a comments feed which validates perfectly. We're all good, at last! The new code used in the tutorial was found here. Many thanks to Anu Gupta for posting them at his blog. End Update.

Update 4.10.06: Nope, the instructions are still not quite right. Apparently this is a trickier hack than I thought… I've changed the commenst feed here to use the instructions at TypePad Tips. I'd like to get the feed working so it displays comments only, as individual items, without the posts. I'll post a notice when I get the new feed to validate. End Update.

Update: 4.4.06: There was an error in the code I posted which caused comments to take on the date of the post they commented on. Thanks to Laura at the TypePad Help Desk, I think I have it all ironed out now. I've replaced the code example in this Hack with the new, improved version. If you used this tutorial for a feed from your own blog, you should replace the code too! End Update.

I read almost all the blogs I follow using RSS. Unless I want to comment on a post, or have just found a new blog via a link, I rarely see blogs in the browser. That's the way I like it— I never miss a post and I don't have to navigate all over the web to keep up. However…

Some blogs develop a community that contributes as much to the content as the author. And already, it looks like this may become one of those blogs. The readers (that's you) have been leaving some very on-target and interesting comments, which means that if you were only reading this blog via RSS you'd be missing out on half the fun! Until now, that is. Today I added a brand new feed to allow you to subscribe to the comments as well. So if you see something that makes you want to jump into the conversation, it's easy. Click the RSS icon in the sidebar that says "join the conversation" to subscribe.

For the moment, I'm planning to offer only two feeds, one for the posts and one for the comments. I feel that's the most efficient way to do it— people can subscribe to one, the other or both. If you'd like to see an additional feed that includes both, let me know in the comments section and I'll put one together.

Building this feed took me longer than I thought it would, but it won't take you any time at all: I've included simple instructions with cut+paste code in the extended entry. Follow the "continue reading" link to get it.

But first, I want to give credit to the three bloggers who posted examples that I used to work from.

Bud at TypePadTips.com posted a very clear and concise set of instructions for building a feed that includes both comments and posts. He was also really helpful when I was struggling to get it to work the way I wanted.

I also found instructions at Matthew Oliphant's blog, usabilityworks.org.

and also, these instructions at revjim.net.

I tried all three of the above today, as well as various edited versions and combinations. I ended up finally using the version from revjim, verbatim, because I had the best luck validating it. All three versions turned up with minor errors* but seem to work in most feed readers except Thunderbird. If anyone out there has a suggestion as to how to fix the code so Thunderbird can read it, I'm all ears.

*Clarification: All three of the feeds above do validate and have been in use by the owners for some time… Bud wrote to inform me that "the content of posts are often the cause of the feedvalidator 'warnings,' and not the feed itself." My mistake.

Okay, click below and let's go get you your own comments feed!

  1. Log into your TypePad Pro account. (You must be using advanced templates in order to create this feed.)
  2. Go to the Design tab for the blog to which you wish to add a comments feed.
  3. Click on “Create new Index Template” (in the top right corner of the page area where your templates are listed).
  4. Type “Comments Feed” (or whatever title you like, actually) in the “Template Name” box.
  5. Type “comments.rdf” in the “Output File” box.
  6. Paste the following code in “Template Body” box:

    <?xml version="1.0" encoding="utf-8"?>

    <rdf:RDF
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
      xmlns:admin="http://webns.net/mvcb/"
      xmlns:content="http://purl.org/rss/1.0/modules/content/"
      xmlns:cc="http://web.resource.org/cc/"
      xmlns="http://purl.org/rss/1.0/">

    <channel rdf:about="<$MTBlogURL$>">
            <title><$MTBlogName encode_xml="1"$> - The Conversation</title>
    <link><$MTBlogURL$></link>
    <description>Comments: <$MTBlogDescription encode_xml="1"$></description>
    <dc:language><$MTBlogLanguage$></dc:language>
    <dc:creator></dc:creator>
    <dc:date><MTEntries lastn="1"><$MTEntryDate format_name="W3CDTF"$></MTEntries></dc:date>
    <admin:generatorAgent rdf:resource="http://www.typepad.com/?v=<$MTVersion$>" />
    <MTBlogIfCCLicense>
    <cc:license rdf:resource="<$MTBlogCCLicenseURL$>" />
    </MTBlogIfCCLicense>

    <items>
    <rdf:Seq><MTComments lastn="25" sort_order="descend">
    <rdf:li rdf:resource="<MTCommentEntry><$MTEntryPermalink encode_xml="1"$></MTCommentEntry>#c<$MTCommentID$>" />
    </MTComments></rdf:Seq>
    </items>
    </channel>

    <MTComments lastn="25" sort_order="descend">
    <item rdf:about="<MTCommentEntry><$MTEntryPermalink encode_xml="1"$></MTCommentEntry>#c<$MTCommentID$>">
    <title>Comment by <$MTCommentAuthor encode_xml="1"$> on "<MTCommentEntry><$MTEntryTitle encode_xml="1"$></MTCommentEntry>"</title>
    <link><MTCommentEntry><$MTEntryPermalink encode_xml="1"$>#c<$MTCommentID$></MTCommentEntry></link>
    <description><$MTCommentBody encode_xml="1"$></description>
    <content:encoded><$MTCommentBody encode_xml="1"$></content:encoded>
    <dc:subject><MTCommentEntry><$MTEntryTitle encode_xml="1"$></MTCommentEntry></dc:subject>
    <dc:creator><$MTCommentAuthor encode_xml="1"$></dc:creator>
    <dc:date><$MTCommentDate format_name="W3CDTF"$></dc:date>
    </item>
    </MTComments>

    </rdf:RDF>

  7. Click “SAVE”.
  8. Click “PUBLISH”.
  9. Wait for the window to pop-up.
  10. Click “PUBLISH” on the new window.
  11. Announce in your blog that you now have a comments feed. Yay! You rock.

I recommend testing the feed with FEEDValidator before adding it to your sidebar.

You'll need the URL for the feed which will be http://www.yourblogname.typepad.com/comments.rdf

Once you've tested your new comments feed with FEEDValidator and tried it out in a reader or two, you'll want to add a link to it in a typelist in your sidebar. Go to feedicons.com for a copy of the "official" RSS icon that is quickly becoming the standard.

Tags: , , , ,

More Like This: Hacks for Comments , Hacks for RSS

Comments

Timothy Appnel says:

I've been subscribed to your comments feed for a week now and I'm noticing some really peculiar behavior. Seems the comments


What happens is my aggregator says there are new items in the feed, but instead of being at the top where the latest items would appear I have to scroll way down. What I also noticed is that the comments were being groups by the entry they were made on. I cracked opened the feed source and sure enough the comments have the same identical timestamp.

Assuming you are using the same source as in this post I think you've stumbbled over a bug or at least an unintentional feature in TypePad.

<dc:date><$MTCommentDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></dc:date>

This line makes total sense still its inserting the entry date instead.

I'm a MT pro by trade, but I'm will to take a guess that the problem is being caused by the MTCommentEntry tagset. If I'm correct change that block to the following should fix it.

    <MTComments lastn="15">
            <item rdf:about="<MTCommentEntry><$MTEntryLink$ encode_xml="1">#<$MTCommentID pad="1"$></MTCommentEntry>">
                <title><$MTCommentAuthor encode_xml="1"$> comments on "<$MTEntryTitle encode_xml="1"$>"</title>
                <description><$MTCommentBody encode_xml="1"$></description>
                <link><MTCommentEntry><$MTEntryLink encode_xml="1"$>#<$MTCommentID pad="1"$></MTCommentEntry></link>
                <dc:contributor><$MTCommentAuthor encode_xml="1"$></dc:contributor>
                <dc:date><$MTCommentDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></dc:date>
            </item>
</MTComments>

Hopefully that helps. I'd like to at least monitor the conversations and thoughts of TypePad user, but with this issues its rather difficult.

john t unger says:

Hi Tim,

Thanks bigtime for the head's up on the weird behavior and the revised code.

I resubscribed to the comment feed to see what you meant about the comments not being in order… I like having them grouped by entry, but you're right, the order is incorrect. I hadn't kept the comments in my feed because I also get them via email.

I wasn't able to get the revised code saved to the feed template, however. When I republish, I get the standard automated dialogue box "TypePad has encountered an error. The requested action could not be completed."

It's great to have people like yourself subscribing, who have a better grasp of the code and can make corrections when needed. Very helpful! Any further thoughts?

john t unger says:

The code in this entry has been adjusted to fix the error noted above.

Marjolein Hoekstra says:

Hi,

I wanted to let you know that I created an RSS 2.0 version of the index template that you offered. I basically took the RSS 2.0 index template offered by TypePad and then used your template to 'fill in the blanks'.
You can see the result of this feed at CleverClogs Comments Feed (original), which I then CSSified using FeedBurner: CleverClogs Comments (FeedBurner version).

Here's the code to put in your template:

<?xml version="1.0" encoding="utf-8"?>
<rss
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:content="http://purl.org/rss/1.0/modules/content/"
 version="2.0">
<channel>
<title><$MTBlogName remove_html="1" encode_xml="1"$> : The Conversation</title>
<link><$MTBlogURL$></link>
<description>Comments: <$MTBlogDescription remove_html="1" encode_xml="1"$></description>
<language><$MTBlogLanguage$></language>
<lastBuildDate><MTEntries lastn="1"><$MTEntryDate format="%a, %d %b %Y %H:%M:%S %z" language="en_US"$></MTEntries></lastBuildDate>
<generator>http://www.typepad.com/</generator>
<MTComments lastn="25" sort_order="descend">
<item>
<title>Comment by <$MTCommentAuthor encode_xml="1"$> on "<MTCommentEntry><$MTEntryTitle encode_xml="1"$></MTCommentEntry>"</title>

<link><MTCommentEntry><$MTEntryPermalink encode_xml="1"$>#c<$MTCommentID$></MTCommentEntry></link>
<guid isPermaLink="true"><MTCommentEntry><$MTEntryPermalink encode_xml="1"$>#c<$MTCommentID$></MTCommentEntry></guid>
<description><$MTCommentBody encode_xml="1"$></description>
<dc:creator><$MTCommentAuthor encode_xml="1"$></dc:creator>
<MTIfNonEmpty tag="MTCommentDate" format="%a, %d %b %Y %H:%M:%S %z" language="en_US"><pubDate><$MTCommentDate format="%a, %d %b %Y %H:%M:%S %z" language="en_US"$></pubDate></MTIfNonEmpty>

</item>
</MTComments>
</channel>
</rss>

Now I'll add this to the auto-discovery section of my page header and a tiny subscription icon in the sidebar.

Timothy Williamson says:

Great site!

I have implemented the comments feed but would also like to offer a feed that shows both the post and any comments made on it. I've tried one of the suggested solutions, but is it possible to get the feed to update when a comment is added?

In other words, when someone comments, can the feed republish the post along with the comment?

Ricky Cadden says:

Thanks for such a great site, first off. I use it all the time making little changes here and there.

However, in implementing this code, I tried both the rdf one in the original post and the rss one in the comments, and when validating either, I get:

line 1, column 2: XML parsing error: :1:2: xml declaration not at start of external entity

Any help? I'm a total newb to all this, but I can copy/paste like a pro.

Mike says:

John,

I just tried this and it works great. Thanks for posting this.

Mike

Jessica Thompson says:

Thank you! This still works. Very happy to find it.

Aravindan N says:

I used your RSS2.0 version and I am able to get the comments as feeds. Thanks.

I have more than 250 comments in the blogs but it retrieves only latest 100 comments where as I update the lastn attribute value to 250 and added the sort_order="descend"

<MTComments lastn="250" sort_order="descend" >

Can you guys help me to retrieve all the comments grouped based on post and then sorted in descended commented date order?

It would be even helpful if you can provide the code snippet which can return the count of comments in the entire blog.

Thanks,
Aravindan N

The comments to this entry are closed.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341c4fdf53ef00d8345d052269e2

Listed below are links to weblogs that reference How to Make Following the Conversation Easy with a Comments Feed:

» Movable Tips. from Code > Appnel Internet Solutions
Here are some notable links to MT tips and techniques from around the net. [Read More]

» Comments feed from Adventures
I have managed to set up a brand new comments feed, thanks to the helpful folks at Typepad Hacks. If you want to keep track of what people are saying every once in a while on my blog, then please [Read More]

typepad hacks is a typepad featured weblog typepad hacks is listed on Alltop social media

Subscribe

Email RSS Comments  
Subscribe to TypePad Hacks with email Read TypePad Hacks posts via RSS Join the conversation at TypePad Hacks via RSS (comments feed) subscriber count

Search

Socialize

Twitter Logo
    follow typepadhacks on twitter

    Read and reply to the 100 most recent comments at the TypePad Hacks Community Page


    Grazr

    Colophon

    Powered by TypePad
    Member since 03/2005

    TypePad Status

    Creative Commons License