- 2008年2月13日 17:28
- MTカスタマイズ | MovableType


コメントのRSSを生成するテンプレートを紹介されているサイトさまをメモしてみました。
ところどころで見られる、コメントRSSなんですが(WordPressとかでよくみるような気が)、ものは試しというか、作ってみることに。過去にMTでコメントのRSSの作成方法を紹介されているサイトさまがいくつかみられましたので、当エントリにてメモという形とさせていただきます。
- コメントRSSの設定とエントリー評価の仕組みを導入(Movable Type) (smashmedia)
- Modern Syntax : MTのコメントをRSS化
- 小粋空間: Movable Type でコメント用 RSS フィードを出力する
以上は、RSS2.0で作られた場合のテンプレートです。
RSS1.0 で RDFファイルにて生成される方法を紹介されているサイトさまはこちら。
フィードの配信でRSSのバージョンはどちらでも構わないと思います。
で、ワタくシの場合は、RSS1.0のほうでやってみました。拙作のテンプレートは以下。上記のサイトさまとほとんど変わりがないというか、MT3のときにあったrdfファイルをベースにしたようなものなので。。。好みのものをお使いになったらいいのではないでしょうか。
<$MTHTTPContentType type="application/rss+xml"$><?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF
xmlns="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel rdf:about="<$MTBlogURL$>cmtrss.rdf">
<title><$MTBlogName remove_html="1" encode_xml="1"$> - コメントフィード</title>
<link><$MTBlogURL$></link>
<description><$MTBlogName remove_html="1" encode_xml="1"$>への新着コメント5件です</description>
<dc:language><$MTDefaultLanguage$></dc:language>
<dc:creator><$MTBlogName remove_html="1" encode_xml="1"$></dc:creator>
<dc:date><MTComments lastn="1"><$MTCommentDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></MTComments></dc:date>
<items>
<rdf:Seq>
<MTComments lastn="5" sort_order="descend"><rdf:li rdf:resource="<MTCommentEntry><$MTEntryPermalink encode_xml="1"$></MTCommentEntry>#comment<$MTCommentID$>" />
</MTComments>
</rdf:Seq>
</items>
</channel>
<MTComments lastn="5" sort_order="descend">
<item rdf:about="<MTCommentEntry><$MTEntryPermalink encode_xml="1"$></MTCommentEntry>#comment<$MTCommentID$>">
<title><MTCommentEntry><$MTEntryTitle remove_html="1" encode_xml="1"$></MTCommentEntry></title>
<link><MTCommentEntry><$MTEntryPermalink encode_xml="1"$>#comment<$MTCommentID$></MTCommentEntry></link>
<dc:creator><$MTCommentAuthor$></dc:creator>
<dc:date><$MTCommentDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></dc:date>
<content:encoded><![CDATA[<$MTCommentBody$>]]></content:encoded>
</item>
</MTComments>
</rdf:RDF>
IE7・Firefox2のブラウザ、Bloglinesにて表示を確認しております。
なお、RDFファイルがIEからみると、ダウンロードになるので以下の記述を.htaccessに追記
AddType "application/xml" .rdf
- Newer: はてブのヘルプページが不親切だったかもというお話
- Older: 記事作成者と他のコメンターとのスタイル分け