Created
March 10, 2013 03:34
-
-
Save KIASMA/5126997 to your computer and use it in GitHub Desktop.
Movable Type 5.2.* 、プラグイン「FiscalYearlyArchivesプラグイン」を用いています。カテゴリアーカイブにおいて、年度別ブログ記事一覧を 1)<table>で出力 2)年度を<th>に記述しますが、同じ年度なら繰り返し<th>に出さないようにrowspanでまとめるためのコードです。出力結果キャプチャ→ http://kiasma.info/gists/20130310.png
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <$MTBlogID setvar="this_blog_id"$> | |
| <$MTCategoryLabel remove_html="1" setvar="current_category_label"$> | |
| <MTIgnore> | |
| // <MTBlogs blog_ids="$this_blog_id">を記述しているのは | |
| // カテゴリアーカイブのコンテキストを脱出して | |
| // <MTArchiveList archive_type="FiscalYearly">を使えるようにするため | |
| </MTIgnore> | |
| <MTBlogs blog_ids="$this_blog_id"> | |
| <MTArchiveList archive_type="FiscalYearly"> | |
| <MTArchiveListHeader> | |
| <table style="border:1px solid;"> | |
| </MTArchiveListHeader> | |
| <MTIgnore></MTIgnore> | |
| <MTIgnore> | |
| // 「年度」すなわち「年度」を消して4桁の数字としての年度を | |
| // 変数 check_archive_title にセット | |
| </MTIgnore> | |
| <$MTArchiveTitle replace="年度","" setvar="check_archive_title"$> | |
| <MTIgnore> | |
| // rowspan 取得用の変数 count を設置 | |
| // 初期値は0 | |
| </MTIgnore> | |
| <$MTSetVar name="count" value="0"$> | |
| <MTIgnore> | |
| // 1回目の MTEntries ループ | |
| // 目的は rowspan 数の取得 | |
| // ちなみに <MTArchiveList archive_type="FiscalYearly"> 内の MTEntries なので | |
| // 年度分× MTEntries というループになる | |
| </MTIgnore> | |
| <MTEntries category="$current_category_label"> | |
| <MTIgnore> | |
| // ブログ記事の年度を変数 archive_fiscal_year にセット | |
| // ちなみに<$MTArchiveFiscalYear$>には「年度」が付随しない | |
| </MTIgnore> | |
| <$MTArchiveFiscalYear setvar="archive_fiscal_year"$> | |
| <MTIgnore> | |
| // 変数 archive_fiscal_year と 変数 check_archive_title を比較 | |
| // 同じ値なら rowspan 取得用の変数 count をインクリメント | |
| </MTIgnore> | |
| <MTIf name="archive_fiscal_year" eq="$check_archive_title"> | |
| <$MTGetVar name="count" op="++" setvar="count"$> | |
| </MTIf> | |
| </MTEntries> | |
| <MTIgnore> | |
| // この時点で各年度ごとの rowspan 数が取得できている | |
| // 2回目の MTEntries ループで実 HTML を生成 | |
| </MTIgnore> | |
| <MTEntries category="$current_category_label"> | |
| <tr> | |
| <MTIgnore> | |
| // __first__ を用いて MTEntries ループ内の1回目の時のみ | |
| // 取得した rowspan 数を反映した <th> を出力 | |
| </MTIgnore> | |
| <MTIf name="__first__"><th style="border:1px solid;" rowspan="<$MTGetVar name="count"$>"><$MTArchiveTitle$></th></MTIf> | |
| <td style="border:1px solid;"><$MTEntryTitle$></td> | |
| </tr> | |
| </MTEntries> | |
| <MTArchiveListFooter> | |
| </table> | |
| </MTArchiveListFooter> | |
| </MTArchiveList> | |
| </MTBlogs> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment