<mt:If name="page_archive">
<mt:PageFolder><mt:FolderId setvar="my_fid"></mt:PageFolder>
<mt:If tag="pageFolder">
<mt:HasParentFolder>
<mt:ParentFolder>
<ul><mt:SubFolders><li>兄弟: <mt:FolderLabel></li></mt:SubFolders></ul>
</mt:ParentFolder>
<mt:Else>
<mt:TopLevelFolders>
<mt:FolderId setvar="this_fid">
<mt:If name="this_fid" eq="$my_fid">
<ul><mt:SubFolders><li>自分の子: <mt:FolderLabel></li></mt:SubFolders></ul>
</mt:If>
</mt:TopLevelFolders>
</mt:HasParentFolder>
</mt:If><!-- /if tag="pageFolder" -->
</mt:If><!-- /if name="page_archive" -->
[mt:If tag="pageFolder"]は、
フォルダ指定なしページの時に mtHasParentFolder で再構築エラーになるので後から追加した。フォルダなしならコンディショナルタグ HasParentFolderがfolseを返せばいいだけなんじゃないかと思うんだけど、なぜだかそのようには動いてくれてないみたい。
例えば 「Movable Type 5 ドキュメント|movabletype.jp」のような目次的なページで、
個々のページはウェブページで生成し、適当な章立てをしつつ見せたい、なんていう時にページ追加・削除時のメンテを少しだけ楽にする書き方を工夫してみた。
前提として、
* 個々のページはウェブページで作成し、章をプライベートタグで入れておく 。
* 目次ページ自身はインデックスアーカイブか、ウェブページにmteval=”1″を指定して生成する。
<mt:SetHashVar name="section"> <$mt:SetVar name="01" value="@インストールと初期設定"$> <$mt:SetVar name="02" value="@アップグレード"$> <$mt:SetVar name="03" value="@フォームの作成(基本操作)"$> <$mt:SetVar name="04" value="@管理画面の操作"$> <$mt:SetVar name="05" value="@フォームのデザインカスタマイズ"$> <$mt:SetVar name="06" value="@開発者向けガイド"$> <$mt:SetVar name="07" value="@セキュリティ、死活監視"$> <$mt:SetVar name="08" value="@各種リファレンス"$> </mt:SetHashVar> <mt:Loop name="section" sort_by="key"> <h2><$mt:Var name="__value__" replace="@","" $></h2> <ul> <mt:Pages folder="A-Form/ドキュメント" tags="$__value__" sort_by="title" sort_order="ascend"> <li><a href="<$mt:PagePermalink$>"><$mt:PageTitle remove_html="1"$></a></li> </mt:Pages> </ul> </mt:Loop>
この方法のポイントは、プライベートタグ設定など適度に手動制御部分を残しつつ、判定文はいっさい書き足さずにメンテできるところでして、
* 章の順番を自由に制御できる。
* タグベースなのであるページを複数の章に所属させたい時にも対応できる。
* 章を増やす時はmt:SetHashVar部分に1行を書き足すだけでよくて、面倒っちぃ判定文を書き足す必要がない。
せいぜい数十ページ程度までの小規模な目次ページなら小回りがきいてオススメな感じ ^^
逆にページ数が膨大な場合はプライベートタグの設定がかえって面倒で、あまりメリットはでない。
あと、印象として再構築がやや長めかもしれない。
<mt:Loop name=”section” sort_by=”key”>
<h2><$mt:Var name=”__value__” replace=”@”,”" $></h2>
<ul>
<mt:Pages folder=”A-Form/ドキュメント” tags=”$__value__” sort_by=”title” sort_order=”ascend”>
<li><a href=”<$mt:PagePermalink$>”><$mt:PageTitle remove_html=”1″$></a></li>
</mt:Pages>
</ul>
</mt:Loop>
カスタムフィールドのテキストエリアに入力した改行をページに反映させるには
<$mt:CustomFieldHoge filters="__default__"$>
のように書く。
以上
【ネタ元】カスタムフィールドのテキストエリアに入力した改行をページに反映させる – 小粋空間
http://www.koikikukan.com/archives/2008/03/18-005038.php
ハッシュを使う。ブログ記事とウェブページ両方あわせたなかから新着N本だけ出すところは、keyを記事生成日にし、keyでソートすればいい。
<mt:Ignore><!-- 初期設定(キーワードと最大記事数) --></mt:Ignore>
<mt:SetVar name="keyword_name" value="kw_ほげ">
<mt:SetVar name="max_cnt" value="3">
<mt:Ignore><!-- ウェブページとブログ記事から各$max_cnt点ずつ新着を取得し、ハッシュにつっこむ --></mt:Ignore>
<mt:Entries lastn="$max_cnt" exclude_blogs="13,14,15" tag="$keyword_name">
<mt:EntryDate format="%Y%m%d%H%M" setvar="entry_date">
<mt:SetVarBlock name="out_html{$entry_date}">
<mt:EntryTitle>
</mt:SetVarBlock>
</mt:Entries>
<mt:Pages lastn="$max_cnt" exclude_blogs="13,14,15" tag="$keyword_name">
<mt:PageDate format="%Y%m%d%H%M" setvar="entry_date">
<mt:SetVarBlock name="out_html{$entry_date}">
<mt:PageTitle>
</mt:SetVarBlock>
</mt:Pages>
<mt:Ignore><!-- keyで並べ替えてmax_cnt個を出力 --></mt:Ignore>
<mt:Loop name="out_html" sort_by="key reverse">
<mt:If name="__counter__" le="$max_cnt">
<$mt:Var name="out_html{$__key__}"$>
</mt:If>
</mt:Loop>
前回、「[MT]今日以降の2ヶ月分のエントリー一覧を表示する」で、
* 今日以降のエントリーを
* 月ごとに表示する
のを試してみた。発展系でさらに、
* table表示に対応し、同月エントリー行の”月”欄はrowspanでくくられるようにする
* 月あたり最大10件まで表示
* 該当エントリーなしの月は月名だけの空行を表示する
ようにしてみた。
同月エントリー行の”月”をrowspanでくくるのが案外面倒だった。方針として、
* あらかじめその月の該当エントリーをリストアップして、該当エントリー数を取得 (rowspan=”N”に使う)
* 同時に、エントリーの内容もハッシュに保存しておく
* 最後に、一気に1ヶ月分のtableデータを出力
とすることで解決した。
<mt:Ignore><!--=== サブルーチンみたいなもん[MonthlyEvent] === --></mt:Ignore>
<mt:SetVarTemplate name="MonthlyEvent">
<mt:Ignore><!-- 月ごとの変数を初期化 --></mt:Ignore>
<mt:SetVar name="monthly_cnt" value="0"><mt:Ignore><!-- 今月のエントリー数カウンタ --></mt:Ignore>
<mt:SetVar name="tag_htmls" function="undef"><mt:Ignore><!-- ハッシュのクリア --></mt:Ignore>
<mt:Ignore><!-- ハッシュにテーブル要素を蓄積 --></mt:Ignore>
<mt:Calendar month="$this_ym">
<mt:CalendarIfToday>
<mt:SetVar name="after_today" value="1">
<mt:Ignore><!-- 今日だったらフラグis_todayに"1"をセット --></mt:Ignore>
</mt:CalendarIfToday>
<mt:If name="after_today" eq="1"><mt:Ignore><!-- 今日以降なら --></mt:Ignore>
<mt:CalendarIfEntries>
<mt:Entries>
<mt:If name="monthly_cnt" lt="10"><mt:Ignore><!-- 今月10件以下なら --></mt:Ignore>
<mt:Ignore><!-- ハッシュに値をセット --></mt:Ignore>
<mt:SetVarBlock name="tag_htmls" function="push">
<td><mt:EntryDate format="%e日"><mt:EntryDate format="%a" setvar="youbi"><mt:if name="youbi" like="日"><span style="color:red">(日)</span><mt:elseif like="土"><span style="color:blue">(土)</span><mt:else>(<mt:Getvar name="youbi">)</mt:if></td>
<td><a href="<mt:EntryPermalink abs2rel="1">" title="<mt:EntryTitle>"><mt:EntryTitle></a></td>
</tr>
</mt:SetVarBlock>
<mt:SetVar name="monthly_cnt" op="++"><mt:Ignore><!-- 今月のエントリー数カウンタを+1 --></mt:Ignore>
</mt:If>
</mt:Entries>
</mt:CalendarIfEntries>
</mt:If>
</mt:Calendar>
<mt:Ignore><!-- /ハッシュにテーブル要素を蓄積 --></mt:Ignore<mt:Ignore><!-- ここからテーブル要素出力 --></mt:Ignore>
<mt:If name="monthly_cnt" eq="0"><mt:Ignore><!-- 0個の時 --></mt:Ignore>
<tr>
<td valign="top"><mt:Var name="this_month"></td>
<td>(ないぉ)</td>
<td>(ないぉ)</td>
</tr>
<mt:Else>
<mt:Loop name="tag_htmls" sort_by="key">
<mt:If name="__first__"><mt:Ignore><!-- ≠0, 1つめheadder --></mt:Ignore>
<tr>
<td valign="top" rowspan="<mt:Var name="monthly_cnt">"><mt:Var name="this_month"></td>
<mt:Else><mt:Ignore><!-- ≠0, 2つめ以降headder --></mt:Ignore>
<tr>
</mt:If>
<MTVar name="__value__"><mt:Ignore><!-- ハッシュ値出力 --></mt:Ignore>
</mt:Loop>
</mt:If><mt:Ignore><!-- /テーブル要素出力 ここまで --></mt:Ignore>
</mt:SetVarTemplate>
<mt:Ignore><!-- === サブルーチンみたいなもん[GetNextMonth] === --></mt:Ignore>
<mt:SetVarTemplate name="GetNextMonth">
<mt:If name="this_month" eq="12"><!-- 12月なら年送り処理をする -->
<mt:SetVar name="this_month" value="01">
<mt:SetVar name="this_year" op="++">
<mt:Else>
<mt:SetVar name="this_month" op="++">
</mt:If>
<mt:SetVarBlock name="this_ym"><mt:GetVar name="this_year"><mt:GetVar name="this_month" zero_pad="2"></mt:SetVarBlock>
</mt:SetVarTemplate>
<mt:Ignore><!-- 実際の処理はここから --></mt:Ignore>
<mt:SetVar name="after_today" value="0"><mt:Ignore><!-- 今日以降かの判定フラグを初期化 --></mt:Ignore>
<mt:Ignore><!-- 再構築日(≒今日)の年をyyyymmフォーマットで取得 --></mt:Ignore>
<mt:Date format="%Y" setvar="this_year">
<mt:Date format="%b" setvar="this_month">
<mt:Date format="%Y%m" setvar="this_ym">
<table width="80%" border="1" cellpadding="2" cellspacing="2" id="event-info">
<tr>
<th>月</th>
<th>日</th>
<th><span>イベント内容</span></th>
</tr>
<mt:Ignore><!-- 今月の処理 --></mt:Ignore>
<mt:GetVar name="MonthlyEvent"
<mt:Ignore><!-- 来月の処理 --></mt:Ignore>
<mt:GetVar name="GetNextMonth">
<mt:GetVar name="MonthlyEvent">
<mt:Ignore><!-- さ来月の処理 --></mt:Ignore>
<mt:GetVar name="GetNextMonth">
<mt:GetVar name="MonthlyEvent">
</table>
実際の処理本体部分はこんな感じ。
繰り返し処理部分は2つのmt:SetVarTemplate でサブルーチン化しているので一見シンプル。
ちなみに、SetVarTemplateではそれぞれ↓こういう処理をしている(後述)。
* GetNextMonth: 翌月の年月を生成。翌月が年をまたぐ場合の処理。
* MonthlyEvent: 該当月のエントリー数のカウント, 該当エントリーをハッシュに保存していく処理。
<mt:SetVar name="after_today" value="0"><mt:Ignore><!-- 今日以降かの判定フラグを初期化 --></mt:Ignore> <mt:Ignore><!-- 再構築日(≒今日)の年をyyyymmフォーマットで取得 --></mt:Ignore> <mt:Date format="%Y" setvar="this_year"> <mt:Date format="%b" setvar="this_month"> <mt:Date format="%Y%m" setvar="this_ym">
ここで全体の初期値のセットを行っている。
after_today は”今日以降”のエントリーかを判定するフラグ。[MonthlyEvent]の中で、 mt:CalendarIfTodayがtrueになったら”1″にセットされて以降ずっと”1″のまま。
その後、↓tableの開始タグと、見だし行を出力。
<table width="80%" border="1" cellpadding="2" cellspacing="2" id="event-info"> <tr> <th>月</th> <th>日</th> <th><span>イベント内容</span></th> </tr>
これ以降、今月, 来月, さ来月のデータを出力(実処理はサブルーチン内で出力)
<mt:Ignore><!-- 今月の処理 --></mt:Ignore> <mt:GetVar name="MonthlyEvent"> <mt:Ignore><!-- 来月の処理 --></mt:Ignore> <mt:GetVar name="GetNextMonth"> <mt:GetVar name="MonthlyEvent"> <mt:Ignore><!-- さ来月の処理 --></mt:Ignore> <mt:GetVar name="GetNextMonth"> <mt:GetVar name="MonthlyEvent">
最後に、tableの終了タグを出力しておしまい。
</table>
翌月の年月を生成。翌月が年をまたぐ場合の処理をしている部分。
<mt:SetVarTemplate name="GetNextMonth"> <mt:If name="this_month" eq="12"> <mt:SetVar name="this_month" value="01"> <mt:SetVar name="this_year" op="++"> <mt:Else> <mt:SetVar name="this_month" op="++"> </mt:If>
前段で年をまたぐ場合の月送り処理をして、最後の行↓で、this_ym に”%Y%m”フォーマットのデータをセットしている。
mt:Calendar month=”$this_ym”で使えるフォーマット(YYYYMM)を得るためにわざわざ月と年にバラしてから月を+1して再び合体するということをしている。
月にzero_pad=”2″を指定している部分がキモ。ちと苦労した部分。
<mt:SetVarBlock name="this_ym"> <mt:GetVar name="this_year"><mt:GetVar name="this_month" zero_pad="2"> </mt:SetVarBlock> </mt:SetVarTemplate>
3つのパートに分かれている。最初はローカル変数の初期化みたいなことをしている部分。
<mt:Ignore><!-- 月ごとの変数を初期化 --></mt:Ignore> <mt:SetVar name="monthly_cnt" value="0"><mt:Ignore><!-- 今月のエントリー数カウンタ --></mt:Ignore> <mt:SetVar name="tag_htmls" function="undef"><mt:Ignore><!-- ハッシュのクリア --></mt:Ignore>
2番目のパートではmt:Calendar month=”$this_ym” ブロックタグ内で、ここでは
* “今日以降”になったかどうかのフラグのセット。
* 今日以降なら指定月のエントリーをリストアップして、ハッシュに保存。
* 月のカウンター(monthly_cnt)により、(今日以降の)同月最大10件までのエントリーのみに限る部分の判定。
* このパートを回し終わると その月のエントリー数が得られる(monthly_cnt)。
を行っている。
<mt:Ignore><!-- ハッシュにテーブル要素を蓄積 --></mt:Ignore> <mt:Calendar month="$this_ym"> <mt:CalendarIfToday> <mt:SetVar name="after_today" value="1"> <mt:Ignore><!-- 今日だったらフラグis_todayに"1"をセット --></mt:Ignore></mt:CalendarIfToday> <mt:If name="after_today" eq="1"><mt:Ignore><!-- 今日以降なら --></mt:Ignore> <mt:CalendarIfEntries> <mt:Entries> <mt:If name="monthly_cnt" lt="10"><mt:Ignore><!-- 今月10件以下なら --></mt:Ignore> <mt:Ignore><!-- ハッシュに値をセット --></mt:Ignore> <mt:SetVarBlock name="tag_htmls" function="push"> <td><mt:EntryDate format="%e日"><mt:EntryDate format="%a" setvar="youbi"><mt:if name="youbi" like="日"><span style="color:red">(日)</span><mt:elseif like="土"><span style="color:blue">(土)</span><mt:else>(<mt:Getvar name="youbi">)</mt:if></td> <td><a href="<mt:EntryPermalink abs2rel="1">" title="<mt:EntryTitle>"><mt:EntryTitle></a></td> </tr> </mt:SetVarBlock> <mt:SetVar name="monthly_cnt" op="++"><mt:Ignore><!-- 今月のエントリー数カウンタを+1 --></mt:Ignore> </mt:If> </mt:Entries> </mt:CalendarIfEntries> </mt:If> </mt:Calendar> <mt:Ignore><!-- /ハッシュにテーブル要素を蓄積 --></mt:Ignore>
最後のパートで、1ヶ月分のtable要素を出力。
月のカラムをrowspanしたいために、2番目のパートであらかじめエントリー数(monthly_cnt)を数えておき、最後にまとめて出力処理する、ということになっている。
* <mt:Loop name=”tag_htmls” sort_by=”key”> ~</mt:Loop>ブロック内で1行ずつ順に出力。
* <mt:If name=”__first__”>で、その月の先頭行の場合は、<tr><td rowspan=”※エントリー数値をセット”>をセットしている。
* ハッシュの値を出す部分は、<MTVar name=”__value__”>。
* なお、その月のエントリーが一つもない時は(ないぉ)と表示。
<mt:Ignore><!-- ここからテーブル要素出力 --></mt:Ignore> <mt:If name="monthly_cnt" eq="0"><mt:Ignore><!-- 0個の時 --></mt:Ignore> <tr> <td valign="top"><mt:Var name="this_month"></td> <td>(ないぉ)</td> <td>(ないぉ)</td> </tr> <mt:Else> <mt:Loop name="tag_htmls" sort_by="key"> <mt:If name="__first__"><mt:Ignore><!-- ≠0, 1つめheadder --></mt:Ignore> <tr> <td valign="top" rowspan="<mt:Var name="monthly_cnt">"><mt:Var name="this_month"></td> <mt:Else><mt:Ignore><!-- ≠0, 2つめ以降headder --></mt:Ignore> <tr> </mt:If> <MTVar name="__value__"><mt:Ignore><!-- ハッシュ値出力 --></mt:Ignore> </mt:Loop> </mt:If> <mt:Ignore><!-- /テーブル要素出力 ここまで --></mt:Ignore>
以上でっす。
7/12 追記
「今月10件以下なら・・・」の判定箇所が間違っていたので修正。mt:Entriesの外で判定すると、10件目近くで同日複数エントリーある場合に、10件を超えて表示されてしまう→ハッシュに保存する直前にmt:Ifを移動。
今日以降の2ヶ月分(今月と来月)のイベント情報を表示する、みたいなお題があって
ちょっとやってみた。なんかちょーダサダサなコードかもですがメモしておくー。
<ポイント>
<mt:SetVar name="after_today" value="0"><!--今日以降かの判定フラグを初期化--> <!-- === サブルーチンみたいなもん === --> <mt:SetVarTemplate name="MonthlyEvent"> <div> <mt:Calendar month="$this_ym"> <mt:CalendarIfToday> <!-- 今日だったらフラグis_todayに"1"をセット --> <mt:SetVar name="after_today" value="1"> </mt:CalendarIfToday> <mt:If name="after_today" eq="1"> <!-- 今日以降なら --> <mt:CalendarIfEntries> <mt:Entries> <p><$mt:CalendarDate format="%x"$> <$mt:EntryTitle$></p> </mt:Entries> </mt:CalendarIfEntries> </mt:If> </mt:Calendar> </div> </mt:SetVarTemplate> <!-- 再構築日(≒今日)の年月をyyyymmフォーマットで取得 --> <mt:Date format="%m" setvar="this_month"> <mt:Date format="%Y" setvar="this_year"> <mt:Date format="%Y%m" setvar="this_ym"> <h2>今月</h2> <p>this_year:<mt:GetVar name="this_year"></p> <p>this_month:<mt:GetVar name="this_month"></p> <p>this_year_month: <mt:GetVar name="this_ym"></p> <mt:GetVar name="MonthlyEvent"> <!--来月の処理--> <mt:If name="this_month" eq="12"> <mt:SetVar name="this_month" value="01"> <mt:SetVar name="this_year" op="++"> <mt:Else> <mt:SetVar name="this_month" op="++"> </mt:If> <mt:SetVarBlock name="this_ym"><mt:GetVar name="this_year"><mt:GetVar name="this_month" zero_pad="2"></mt:SetVarBlock> <h2>来月</h2> <p>this_year:<mt:GetVar name="this_year"></p> <p>this_month:<mt:GetVar name="this_month"></p> <p>this_year_month: <mt:GetVar name="this_ym"></p> <mt:GetVar name="MonthlyEvent">
MTのプラグインが書けるようになりたいなーと思って、ただいまPerlとMTのお勉強中。その1。
「あたちもMTのプラグイン書けるようになりたいっ」と社内SEに泣きついたら、「しょーがねーなー」とひと肌脱いでくれまして、先週から社内でMTお勉強会してもらってます。
勉強会のおさらいと、 コードネーム’歩実ちゃん’(知人の子供)誕生を記念して、 赤ちゃん語変換を行うプラグインを書いてみた。
ブロックタグ<mt:BabyTalk> を提供し、このタグで囲まれた範囲内に たとえば「~です。」と書いてあったら「~でちゅ。」になるような。。。
一応マイ・ファースト・MTプラグインでちゅ^^;
とはいえ、自力で1からは無理ぽorz…と思ったので
bzbellさんのプラグイン「RemoveBlank」を参考にさせてもらって、Perlの入門書にあったサンプルコードを 合体ぐにゅぐにゅして作ったですよ ^^;
PlugInソース ちなみに、元の「RemoveBlank」プラグインはこんな感じ。
perlの1ファイルだけの構成。
http://sourceforge.jp/projects/nekotama/downloads/31094/RemoveBlank-1.03.zip/
これをベースに、
1) config.yamlで書いてみた(先週やった勉強会のおさらいさ~)。
Blockタグの宣言は↓こんな風に書けば良いらしい。
cf.) http://www.movabletype.org/documentation/developer/declaring-template-tags.html
tags: block: BabyTalk: $convert_babytalk::BabyTalk::convert_babytalk
で、こうなる↓(むちゃくちゃシンプル ^^;)
/plugins/BabyTalk/config.yaml
name: BabyTalk id: BabyTalk version: 1.0 author_link: http://foxbitz.jp/ author_name: fox_b doc_link: http://foxbitz.jp/doc/ description: Convert text to BabyTalk between a tag. tags: block: BabyTalk: $convert_babytalk::BabyTalk::convert_babytalk
2) RemoveBlankではタグや空行があったら削除変換するところを、赤ちゃん語に変えてplugins/BabyTalk/lib配下に置いただけー。
それが↓コレ
plugins/BabyTalk2/lib/BabyTalk.pm
package BabyTalk;
use strict;
use utf8; # utf8プラグマを有効にする ←6/29追加した
use MT::Template::Context;
use base qw(MT::Plugin);
sub convert_babytalk {
my ($ctx, $args, $cond) = @_;
my $builder = $ctx->stash('builder'); #このへん何やってんのかイマイチわかってないがまーヨシとする
my $tokens = $ctx->stash('tokens');
my $out = $builder->build ($ctx, $tokens, $cond);
return $ctx->error ($builder->errstr) if !defined $out;
my @list = split(/[\r\n]/, $out);
$out = do_convert(@list);
$out;
}
sub do_convert {
my @out = @_;
my $txt = '';
for (@out) {
s/a/(=^..^=)/g; #for debug(なんか日本語だと変換されないから orz...)
s/さ/ちゃ/g;
s/し/ち/g;
s/す/ちゅ/g;
s/せ/ちぇ/g;
s/そ/ちょ/g;
s/。/ばぶー。/g;
$txt .= $_ . "\n" if ($_ ne '');
}
return $txt;
}
1; # Every module must return true
yamlで書いた内容が反映されてる。いえー♪
MTテンプレにタグ埋め込み。
変換前後がわかるようにこんな風に書いた。
<div class="asset-body"> <h2>変換前:</h2> <$mt:EntryBody$> <h2>変換後:</h2> <mt:BabyTalk><$mt:EntryBody$></mt:BabyTalk> </div>
http://mt.foxbitz.jp/b1/blog/2010/06/convert-to-babytalk.html
日本語の変換ができてないーorz….
明日会社に行ったら誰かに教えてもらおう To be continued..
6/29 utf8プラグマを有効にする1行を追加して解決デキタ気がする。
use utf8; # utf8プラグマを有効にする
●参考にしたサイト
Encode – 日本語などのマルチバイト文字列を適切に処理する / Perlモジュール徹底解説 :: サンプルコードによるPerl入門
http://d.hatena.ne.jp/perlcodesample/20091118/1246679588
なおよくわからないこと
今回utf8プラグマの1行追加しただけで動いているっぽいのだけれど、 このプラグインに受け渡される文字列は、すでに”内部文字列”ちゅうやつなんかしら?!
$out を最初と最後にdecode/encodeする必要はあるのかな?!
こーいうのホントは必要だった? MTの仕様を確認すればわかるんかな。。。To be continued…
↓
use Encode qw/encode decode/;
# UTF-8バイト文字列を内部文字列にデコード
$str1 = decode('UTF-8', $str1)
タグリファレンス
http://www.movabletype.jp/documentation/appendices/tags/
判定用のタグ(Conditional)
http://movabletype.jp/cgi-bin/mt4/mt-search.cgi?tag=conditional&blog_id=3&IncludeBlogs=3
アーカイブテンプレート:予約変数による判別
http://www.movabletype.jp/documentation/files/arcive_variable.pdf
* メインページ <mt:If name="main_index"> * archive_index <mt:If name="archive_index"> * individual <mt:If name="entry_archive"> * page <mt:If name="page_archive"> * page&entry <mt:If name="feedback_template"> * 各アーカイブのd/w/m/y <mt:If name="datebased_archive"> * d/w/m/y <mt:If name="datebased_only_archive"> * カテゴリ <mt:If name="category_archive"> * ユーザ別 <mt:If name="author_archive"> * 全archives <mt:If name="archive_template"> * 記事リスト系 <mt:If name="archive_listing">
アーカイブテンプレート:変数archive_classによる判別
<mt:If name="archive_class"
eq="entry-archive"> :: individual
<mt:ElseIf eq="page-archive"> :: page
<mt:ElseIf eq="category_archive"> :: category
<mt:ElseIf eq="datebased-monthly-archive"> :: 月別
<mt:ElseIf eq="author-archive"> :: ユーザ別
</mt:If>
グローバル・モディファイア
http://movabletype.jp/documentation/appendices/modifiers/
環境変数
http://www.movabletype.jp/documentation/appendices/config-directives/
日付のフォーマット
http://www.movabletype.jp/documentation/appendices/date-formats.html
<$MTDate format=”※フォーマット指定※”$>
* format_name="iso8601" 例: 2006-05-23T11:44:09+09:00 * format_name="rfc822" 例: Mon, 23 May 2006 11:44:09 +0900 * language="ja" 例: 2006年05月03日 11:44 * format="%x" 例: 2002年09月06日 ※0補完 * format="%Y年%m月%d日" 例: 2002年09月06日 ※0補完 * format=""%Y年%B月%e日" 例: 2002年 9月6日 ※スペース補完 * format="%A" 例: 火曜日
アーカイブマッピング(ファイル名)
http://www.movabletype.jp/documentation/appendices/archive-file-path-specifiers.html
サイトパス生成メモ
<mt:BlogParentWebsite> <$mt:WebsiteURL setvar="website_url"$> <$mt:WebsiteHost setvar="website_host"$> <$mt:WebsiteRelativeURL setvar="website_path"$> </mt:BlogParentWebsite>
ウェブサイトURL: http://example.com/foo/ とした場合、次のように出力される。
| 項目 | 使い方 | 出力例 |
|---|---|---|
| ホストからの相対パス | <$mt:Var name=’website_path’$>index.html | /foo/index.html |
| URL | <$mt:Var name=’website_url’$>index.html | http://example.com/foo/index.html |
| SSL領域のURL | https://<$mt:Var name=’website_host’$><$mt:Var name=’website_path’$>contact.html | https://example.com/foo/contact.html |
パンくずナビ用メモ。フォルダ1階層前提の猛烈シンプルなやつメモっておく。
<li><a href="/">ホーム</a> ></li>
<mt:unless tag="PageBasename" eq="index">
<li><a href="./"><$mt:FolderLabel$></a> ></li>
</mt:unless>
<li><$mt:PageTitle$></li>
<mt:SetVarBlock name="topicpath">
<a href="<$mt:Var name='website_path'$>index.html" title="ホーム">ホーム</a> »
<mt:If name="main_index"><strong><$mt:BlogName$></strong>
<mt:Else><a href="<$mt:Var name='blog_path'$>index.html" title="<$mt:BlogName$>"><$mt:BlogName$></a> »
</mt:If>
</mt:SetVarBlock>
<mt:If name="page_archive">
<mt:SetVarBlock name="topicpath" append="1">
<mt:Unless tag="PageBasename" eq="index">
<mt:ParentFolders>
<a href="<$mt:BlogURL$><$mt:FolderPath$>"><$mt:FolderLabel$></a> »
</mt:ParentFolders>
<strong><$mt:PageTitle remove_html="1"$></strong>
<mt:Else>
<mt:ParentFolders exclude_current="1">
<a href="<$mt:BlogURL$><$mt:FolderPath$>"><$mt:FolderLabel$></a> »
</mt:ParentFolders>
<strong><$mt:FolderLabel$></strong>
</mt:Unless>
</mt:SetVarBlock>
</mt:If>