<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
タグリファレンス
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 |