一年近く続いてきたこの連載ですが,今日でいよいよ最終回です。残りのテンプレート「最新記事のフィード」を少しカスタマイズした後,サンプルサイトとテンプレートプラグインのご紹介をします。
「最新記事のフィード」をカスタマイズして完成させる
ほげ山くん:先輩,まだいじっていないテンプレートって,「最新記事のフィード」だけなんですよね?
くれま先輩:うん。これを完成させたら,説明は完了だよ!頑張っていきましょ。ではでは,[デザイン→テンプレート]を選択して,インデックステンプレートのセクションの下にある「最新記事のフィード」をクリックしてね。
ほげ山くん:開きました。4.25デフォルトのテンプレートは,こんな感じですね。
4.25デフォルトの「最新記事のフィード」テンプレート
<$mt:HTTPContentType type="application/atom+xml"$><?xml version="1.0" encoding="<$mt:PublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><$mt:BlogName remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$mt:BlogURL encode_xml="1"$>" />
<link rel="self" type="application/atom+xml" href="<$mt:Link template="feed_recent"$>" />
<id>tag:<$mt:BlogHost exclude_port="1" encode_xml="1"$>,<$mt:TemplateCreatedOn format="%Y-%m-%d"$>:<$mt:BlogRelativeURL encode_xml="1"$>/<$mt:BlogID$></id>
<updated><mt:Entries lastn="1"><$mt:EntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></mt:Entries></updated>
<mt:If tag="BlogDescription"><subtitle><$mt:BlogDescription remove_html="1" encode_xml="1"$></subtitle></mt:If>
<generator uri="http://www.sixapart.com/movabletype/"><$mt:ProductName version="1"$></generator>
<mt:Entries lastn="15">
<entry>
<title><$mt:EntryTitle remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$mt:EntryPermalink encode_xml="1"$>" />
<id><$mt:EntryAtomID$></id>
<published><$mt:EntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
<updated><$mt:EntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
<summary><$mt:EntryExcerpt remove_html="1" encode_xml="1"$></summary>
<author>
<name><$mt:EntryAuthorDisplayName encode_xml="1"$></name>
<mt:If tag="EntryAuthorURL"><uri><$mt:EntryAuthorURL encode_xml="1"$></uri></mt:If>
</author>
<mt:EntryCategories>
<category term="<$mt:CategoryLabel encode_xml="1"$>" scheme="http://www.sixapart.com/ns/types#category" />
</mt:EntryCategories>
<mt:EntryIfTagged><mt:EntryTags><category term="<$mt:TagName normalize="1" encode_xml="1"$>" label="<$mt:TagName encode_xml="1"$>" scheme="http://www.sixapart.com/ns/types#tag" />
</mt:EntryTags></mt:EntryIfTagged>
<content type="html" xml:lang="<$mt:BlogLanguage ietf="1"$>" xml:base="<$mt:BlogURL encode_xml="1"$>">
<$mt:EntryBody encode_xml="1"$>
<$mt:EntryMore encode_xml="1"$>
</content>
</entry>
</mt:Entries>
</feed>
くれま先輩:そうそう。このテンプレートが使われて,ブログの公開URL直下に「atom.xml」という名前のファイルが生成されるんだよね。このテンプレートをこのまま使ってもそんなには悪くないんだけど,これだと個々の絵本紹介記事のカスタムフィールドに入力した情報が出力されないのよね。ほら,「atom.xml」の一つ分の記事を見てみると,こんな感じなんだもん。
atom.xmlの一部分を抜粋したもの
<entry>
<title>妖精を見つけた!</title>
<link rel="alternate" type="text/html" href="http://xxx.xxxxxx.xx/gihyo-jp/world/post.html" />
<id>tag:localhost,2008:/xxxxxxxxx//1.202</id>
<published>2009-03-17T17:14:58Z</published>
<updated>2009-05-06T07:21:08Z</updated>
<summary>ある日ベットの下の穴を覗いてみたら,妖精のおうちを見つけてしまった!メアリーと妖...</summary>
<author>
<name>crema</name>
</author>
<category term="海外作家の絵本" scheme="http://www.sixapart.com/ns/types#category" />
<category term="ファンタジー" label="ファンタジー" scheme="http://www.sixapart.com/ns/types#tag" />
<content type="html" xml:lang="ja" xml:base="http://xxx.xxxxxx.xx/gihyo-jp/">
<![CDATA[<p>ある日ベットの下の穴を覗いてみたら,妖精のおうちを見つけてしまった!メアリーと妖精の心温まる冒険物語。</p>]]>
</content>
</entry>
ほげ山くん:うゎ。これを見ても,よくわかんないですね…。
くれま先輩:下から4行目を見てみて。「<![CDATA[<p>ある日ベットの下の穴を覗いてみたら,妖精のおうちを見つけてしまった!メアリーと妖精の心温まる冒険物語。</p>]]>」って出力されているけど,これってブログ記事投稿画面の「本文」欄に入力した内容が「<$mt:EntryBody encode_xml="1"$>」で出力されてるんだよね。
ほげ山くん:あー,なるほど。そうか。他にも「著者名」や「発売日」なんかを投稿したのに,それが出力されてないってことですよね。

