MovableType で携帯用のテンプレートを作ってみた.

この記事は約5分で読めます。

MovableType は標準で携帯に対応していない.
携帯でも読めると便利なので,いろいろ探してみたが,結局自分でテンプレート作ってしまったほうがいろいろ改造も出来るし,便利だという結論に達する.
まず文字コードの問題が存在するわけだが,これは php によって変換.
charset は sjis と宣言しておく.
これをモバイルエントリー・アーカイブとでも言う名前にして,アーカイブで作成する.
公開の設定で,マッピングを新規作成しておけば「再構築」で自動的に携帯用ページも作成される.
出力フォーマットを %y/%m/%b.php のように拡張子は php にしておくこと.
さらに,トップページで携帯かどうかを判別して,今回作った携帯用ページに飛ばす必要もある.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<title><?= mb_convert_encoding('<$MTEntryTitle remove_html="1"$>@@:@<$MTBlogName encode_html="1"$>', "SJIS", "UTF-8") ?> </title>
<link rel="start" href="<$MTBlogURL$>" title="Home" />
</head>
<body onload="individualArchivesOnLoad(commenter_name)">
<h1 id="banner-header"><a href="<$MTBlogURL$>" accesskey="1"><?= mb_convert_encoding('<$MTBlogName encode_html="1"$>', "SJIS", "UTF-8"); ?></a></h1>
<MTEntryPrevious><?
$inStart = strrpos('<$MTEntryPermalink$>', '.');
$stFileNoExt = substr('<$MTEntryPermalink$>', 0, $inStart);
?><a href="<?= $stFileNoExt ?>.php">&laquo; <?= mb_convert_encoding("<$MTEntryTitle$>", "SJIS", "UTF-8"); ?></a></MTEntryPrevious><br>
<MTEntryNext><?
$inStart = strrpos('<$MTEntryPermalink$>', '.');
$stFileNoExt = substr('<$MTEntryPermalink$>', 0, $inStart);
?><a href="<?= $stFileNoExt ?>.php"><?= mb_convert_encoding("<$MTEntryTitle$>", "SJIS", "UTF-8"); ?> &raquo;</a></MTEntryNext><br>
<h3 class="entry-header"><?= mb_convert_encoding(strip_tags( '<$MTEntryTitle$>', "<br>"), "SJIS", "UTF-8") ?></h3>
<?= mb_convert_encoding(strip_tags( '<$MTEntryBody$>', "<br>"), "SJIS", "UTF-8") ?>
投稿者: <$MTEntryAuthorDisplayName$> 日時: <$MTEntryDate$>', "SJIS", "UTF-8") ?>
</body>
</html>