Not a developer? Go to MovableType.com

Documentation

Creating Comment Feeds

Site Wide Comment Feeds

To add a comment feed for your entire blog, create an index template that contains the following contents. Set the output of the Index Template to comments.xml.

<$MTHTTPContentType type="application/atom+xml"$><?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0">
    <title>Comment Feed for <mt:BlogName encode_xml="1"></title>
    <id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTTemplateCreatedOn format="%Y-%m-%d"$>:<$MTBlogRelativeURL encode_xml="1"$>/comments</id>
    <updated><MTComments lastn="1"><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTComments></updated>
    <link rel="self" href="<mt:BlogURL>comments.xml" />
    <generator uri="http://www.sixapart.com/movabletype/"><$MTProductName version="1"$></generator>
<mt:Comments lastn="20">
<entry>
<mt:CommentEntry>
    <id><$MTEntryAtomID$>-comment:<$MTCommentID$></id>
<mt:ifcommentparent>
    <thr:in-reply-to ref="<$MTEntryAtomID$>-comment:<mt:CommentParentID>" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>#comment-<mt:CommentParentID>"/>
<mt:else>
    <thr:in-reply-to ref="<$MTEntryAtomID$>" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>"/>
</mt:ifcommentparent>

    <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>#c<$MTCommentID$>" />
    <title>Comment from <$MTCommentAuthor encode_xml="1"$> on <$MTCommentDate format="%Y-%m-%d"$></title>
    <author>
        <name><$MTCommentAuthor encode_xml="1"$></name>
        <mt:if tag="commenturl"><uri><$MTCommentURL encode_xml="1"$></uri></mt:if>
    </author>
    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTCommentURL encode_xml="1"$>">
        <$MTCommentBody encode_xml="1"$>
    </content>
    <published><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
    <updated><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
</mt:CommentEntry>
</entry>
</mt:Comments>
</feed>

RSS

<$MTHTTPContentType type="application/rss+xml"$><?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rss version="2.0">
   <channel>
      <title><$MTBlogName remove_html="1" encode_xml="1"$>Comments</title>
      <link><$MTBlogURL$></link>
      <description><$MTBlogDescription remove_html="1" encode_xml="1"$></description>
      <language><$MTBlogLanguage ietf="1"$></language>
      <copyright>Copyright <$MTDate format="%Y"$></copyright>
      <lastBuildDate><MTEntries lastn="1"><$MTEntryDate format_name="rfc822"$></MTEntries></lastBuildDate>
      <generator>http://www.sixapart.com/movabletype/</generator>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs>
      <MTComments lastn="15">
      <item>
         <title><$MTCommentAuthor remove_html="1" encode_xml="1"$> said: <$MTCommentBody trim_to="100" encode_xml="1" convert_breaks="0"$></title>
         <description>
           <$MTCommentAuthor remove_html="1" encode_xml="1"$> said: <br /><br />
           <$MTCommentBody encode_xml="1"$><br /><br />
           on the entry <a href="<MTCommentEntry><$MTEntryPermalink encode_xml="1"$></MTCommentEntry>"><MTCommentEntry><MTEntryTitle></MTCommentEntry></a>
         </description>
         <link><MTCommentEntry><$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$></MTCommentEntry></link>
         <guid><MTCommentEntry><$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$></MTCommentEntry></guid>
         <pubDate><$MTCommentDate format_name="rfc822"$></pubDate>
      </item>
      </MTComments>
   </channel>
</rss>

Per-Entry Comment Feeds

To create a comments feed for each entry create an Entry Archive Template with the following contents. Then set the mapping for that template to output a .xml version of the "individual entry archive." Here is a screenshot of what just such a mapping might look like (this creates a mapping for both pages and entries:

comment-feed-map.png

This mapping would be applied to your comment feed, which follows:

<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="<$MTArchiveLink encode_xml="1"$>" />
  <link rel="self" type="application/atom+xml" href="<$MTBlogURL$>atom.xml" />
  <id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$>/<$MTEntryAtomID$>-</id>
  <updated><MTComments lastn="1"><$MTDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTComments></updated>
  <title>Comments for <$MTArchiveTitle remove_html="1" encode_xml="1"$></title>
  <MTIfNonEmpty tag="MTBlogDescription"><subtitle><$MTBlogDescription remove_html="1" encode_xml="1"$></subtitle></MTIfNonEmpty>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>
  <entry>
    <id><$MTEntryAtomID$></id>
    <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
    <link rel="service.edit" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
    <published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
    <updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
    <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
    <summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>
    <author>
      <name><$MTEntryAuthorDisplayName encode_xml="1"$></name>
      <MTIfNonEmpty tag="MTEntryAuthorURL"><uri><$MTEntryAuthorURL encode_xml="1"$></uri></MTIfNonEmpty>
    </author>
    <MTEntryCategories>
    <category term="<$MTCategoryLabel encode_xml="1"$>" />
    </MTEntryCategories>
    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
      <$MTEntryBody encode_xml="1"$>
      <$MTEntryMore encode_xml="1"$>
    </content>
  </entry>
<MTComments>
  <entry>
    <id><$MTEntryAtomID$>-comment:<$MTCommentID$></id>
    <thr:in-reply-to ref="<$MTEntryAtomID$>" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>"/>
    <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>#c<$MTCommentID$>" />
    <title>Comment from <$MTCommentAuthor encode_xml="1"$> on <$MTCommentDate format="%Y-%m-%d"$></title>
    <author>
        <name><$MTCommentAuthor encode_xml="1"$></name>
        <uri><$MTCommentURL encode_xml="1"$></uri>
    </author>
    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTCommentURL encode_xml="1"$>">
        <$MTCommentBody encode_xml="1"$>
    </content>
    <published><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
  </entry>
</MTComments>
</feed>

Finally, you will need to point your Entry Archive template and your Page Archive template at your comment feeds. This is done by editing your Header template and adding the following code:

<MTIf name="page_template">
  <link rel="alternate" type="application/atom+xml" href="<$MTBlogURL$><$mt:FileTemplate format="%-c/%-F-comments.xml" encode_xml="1"$>" title="Comments">
</MTIf>
<MTIf name="entry_template">
  <link rel="alternate" type="application/atom+xml" href="<$MTBlogURL$><$mt:FileTemplate format="%C/%F-comments.xml" encode_xml="1"$>" title="Comments">
</MTIf>

It is critical that the mapping you use in the user interface (see screenshot above) is identical to the mapping you use in your <mt:FileTemplate> template tag.

Back

4 Comments

kelly42.myopenid.com

kelly42.myopenid.com on August 30, 2007, 5:04 p.m. Reply

I’m so pleased to see these examples at last. Thanks for listening and for putting them out for us to use!

However I think the process of creating the archive mapping for the per-entry comment feed could use some additional explanation. I tried to map the per-entry comment feed to use a similar pathname to my individual entry, but that didn’t work - I just ended up making my entries unretrievable instead! Could this be explained a little better, please? I did investigate the archive mapping and archive file path specifier docs elsewhere on the site, but some direct links within this page would be useful to others. Thanks!

(Still no TypePad login for comments on this site?)

kelly42.myopenid.com

kelly42.myopenid.com on September 4, 2007, 11:37 a.m. Reply

Beware the perils of changing archive mappings. I tried to implement the per-entry comment feeds on my blog, failed, and deleted the template I’d created, but have observed a problem where entry pages aren’t published correctly and aren’t integrated into the main index after this.

Perhaps further explanation of the precise way to adjust the archive mappings is necessary here? A link to the explanatory doc on archive mapping could be useful.

kelly42.myopenid.com

kelly42.myopenid.com on September 5, 2007, 2:59 p.m. Reply

Some instruction to users about how NOT to set the per-entry comment feeds as the entry link (which I think happens by checking/unchecking the box next to “Entry” in the archive mapping area) would be most useful. I seem to be able to publish either my entry page or my entry comments but not both.

Byrne Reese

Byrne Reese on September 25, 2007, 3:44 p.m. Reply

@kelly42 - Sorry it has taken me so long to reply, but I have augmented the documentation vis-a-vis setting up your template mappings. I hope it helps.

Leave a Comment