foxbitz
WordPressのアップグレードって楽ちん(^。^)
- 2010-07-31 (土)
- 未分類
このブログをWordPress 3.0.1にした。
いつも感じるけれど、管理画面から[更新]をクリックするだけでいっさいがっさいすんでしまう。本当に楽ちんだ。
[Perlメモ]Windows×ActivePerl動作環境メモ
- 2010-07-25 (日)
- Perl
動作環境メモ
コマンドプロンプトでヘルプ表示
help → コマンドとその概要が一覧表示される help コマンド名 → 指定コマンドの詳しい説明が表示される
任意のディレクトリで .plのスクリプトが動くようにする
毎度、>perl c:\htdocs\perl\hoge.pl と書かなくても >hoge.pl だけで実行できるようにする。
→ PATHを設定する。
例えばいつも.plファイルをc:\htdocs\perl 配下に置くことにしたなら
path c:\htdocs\perl;%PATH%
とすると、現在のPATH設定に目的のパスが追加される。
[MT]あるタグがついたブログ記事, ウェブページの新着N本を出力する
- 2010-07-17 (土)
- MTテンプレ習作 | MovableType
ハッシュを使う。ブログ記事とウェブページ両方あわせたなかから新着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]今日以降の3ヶ月分のエントリー一覧をtable表示する
- 2010-07-12 (月)
- MTテンプレ習作 | MovableType
前回、「[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: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>
サブルーチン mt:SetVarTemplate name=”MonthlyEvent”
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を移動。
[Perlお勉強]繰り返し, reverse, 文字列の繰り返し(x演算子)
- 2010-07-04 (日)
- Perl
ぼちぼちとお勉強してます(-。-)y-゚゚゚
Perl言語プログラミングレッスン 問題6-5 (p173):
わりときれいに解けたので記念に貼っておく。
# 6行と16行の2パターンのクリスマスツリーを作る
use strict;
use warnings;
my @array = qw(* ! * % / * + - ! . * * % / * +);
for my $n(5,15) {
foreach my $i(0..$n) {
my @obverse = @array[0..$i];
my @reverse = reverse(@obverse);
print ' ' x ($n-$i), @obverse, @reverse[1..$i], "\n";
}
}
[MT]今日以降の2ヶ月分のエントリー一覧を表示する
- 2010-06-29 (火)
- MovableType
今日以降の2ヶ月分(今月と来月)のイベント情報を表示する、みたいなお題があって
ちょっとやってみた。なんかちょーダサダサなコードかもですがメモしておくー。
<ポイント>
- 年送りの処理 : 今月が12月なら翌月は1にリセットし、かつ年を+1する。
- <mt:Calendar month=”$this_ym”> で月をYYYYMM形式で渡してあげる必要があるので、$this_ymは年+月で算出し、
かつ月はMM形式になるようzeropad=”2″を使って0を補完する必要あり。単に翌月=今月+1ってやると文字列でなく数値と解釈される模様。
<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お勉強] 赤ちゃん語変換プラグイン – MTBabyTalk
- 2010-06-27 (日)
- MTプラグイン(お勉強中) | MovableType
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テンプレート
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プラグマを有効にする
- 日本語などマルチバイト文字をソース内に記述するときは、ソースコードをUTF-8で保存し、その上でutf8プラグマを有効にする。
- ソースをUTF-8で保存すると、文字列リテラルはUTF-8バイト文字列になる。
- utf8プラグマを有効にすると、UTF-8バイト文字列を内部文字列に変換する。
- 内部文字列同士であれば、正規表現がちゃんと動く。
●参考にしたサイト
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)
[MT備忘録]よく使うリファレンスへのポインタ
- 2010-05-11 (火)
- MovableType
タグリファレンス
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備忘録]サイトパス生成メモ
- 2010-05-09 (日)
- MovableType
サイトパス生成メモ
<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 |
[MT備忘録]パンくず用メモ:ウェブページで自分がindex.htmlならパンくずのフォルダTOPを省略
- 2010-04-08 (木)
- MovableType
パンくずナビ用メモ。フォルダ1階層前提の猛烈シンプルなやつメモっておく。
- ファイル名がindex.html の時 → ホーム > ページタイトル(リンクなし)
- ファイル名がindex以外の時 → ホーム > フォルダ名(リンク) > ページタイトル
<li><a href="/">ホーム</a> ></li>
<mt:unless tag="PageBasename" eq="index">
<li><a href="./"><$mt:FolderLabel$></a> ></li>
</mt:unless>
<li><$mt:PageTitle$></li>
-
- A Wan!derful Travel with Your Dog – 犬を連れて出かけよう! 国内/海外犬連れ旅のTips&Hints。開設して12年ほどになる私の個人サイトです。むしろこれが本サイトw
- delicious (fox_b) 仕事柄、Web関係のブックマークが多いです。
- Twitter (fox_b) Follow me!
-
- 40の手習い
- ActivePerl
- Advanced Tag Entry
- Amie
- awanda.net
- Blog
- Click Tags
- Flickr
- foreach
- Framework
- GoogleAnalytics
- GoogleMaps
- LifeHack
- Lifehacks
- mEditor
- MovableType
- MT
- MT5
- mt:EntryExcerpt
- mt:SetVarTemplate
- MTタグ
- MTテンプレ習作
- MT設定
- Perl
- PlugIn
- PSPad
- reverse
- Tag
- tool
- Twitter フォーム
- Website
- Webデザイン
- WordPress
- ぼやきw
- アーカイブマッピング
- カロリー計算ツール
- サイトパス
- ダイエット
- ツール
- テンプレ実装Tips
- ドトール
- ハッシュ
- ハーブ
- パンくず
- パンくずリスト
- ブロックタグ
- プロボノ
- モバイル環境
- リファレンス
- ローズマリー
- 健康
- 備忘録
- 光が丘
- 文字コード
- 日本語処理
- 犬旅
- 環境変数
- 盲導犬
- 社会貢献



