6.28 月別アーカイブ一覧に年別の見出しを表示する ★
P.511
年別の見出しを降順、月を降順に表示する
●テンプレートをカスタマイズする
「月別アーカイブ」ウィジェットテンプレート(サンプルテンプレート)
<mt:ifArchiveTypeEnabled archive_type="Monthly">
<dt class="sidetitle">月別アーカイブ一覧</dt>
<dd class="side">
<mt:archiveList archive_type="Monthly">
<mt:archiveListHeader>
<ul>
<li><mt:archiveDate format="%Y年" />
<ul>
<mt:archiveDate format="%Y年" setvar="year" />
</mt:archiveListHeader>
<mt:archiveDate format="%Y年" setvar="current_year" />
<mt:if name="current_year" ne="$year">
</ul>
</li>
<li><mt:getVar name="current_year" />
<ul>
</mt:if>
<mt:getVar name="current_year" setvar="year" />
<li><a href="<mt:archiveLink />"><mt:archiveTitle regex_replace="/\d+年/","" /></a> [<mt:archiveCount />]</li>
<mt:archiveListFooter>
</ul>
</li>
</ul>
</mt:archiveListFooter>
</mt:archiveList>
</dd>
</mt:ifArchiveTypeEnabled>
★「月別アーカイブ」ウィジェットテンプレート(デフォルトテンプレート)
元のテンプレートから、008~023の構造を大きく変更しています。処理の流れはサンプルテンプレートと同じです。
001:<mt:IfArchiveTypeEnabled archive_type="Monthly">
002: <mt:ArchiveList archive_type="Monthly">
003: <mt:ArchiveListHeader>
004:<div class="widget-archive-monthly widget-archive widget">
005: <h3 class="widget-header"><$mt:ArchiveTypeLabel$> <a href="<$mt:Link template="archive_index"$>">アーカイブ</a></h3>
006: <div class="widget-content">
007: <ul class="widget-list">
008: <li class="widget-list-item"><mt:archiveDate format="%Y年" />
009: <ul class="widget-list">
010: <mt:archiveDate format="%Y年" setvar="year" />
011: </mt:ArchiveListHeader>
012: <mt:archiveDate format="%Y年" setvar="current_year" />
013: <mt:if name="current_year" ne="$year">
014: </ul>
015: </li>
016: <li class="widget-list-item"><mt:getVar name="current_year" />
017: <ul class="widget-list">
018: </mt:if>
019: <mt:getVar name="current_year" setvar="year" />
020: <li class="widget-list-item"><a href="<$mt:ArchiveLink$>"><$mt:ArchiveTitle regex_replace="/\d+年/",""$> (<$mt:ArchiveCount$>)</a></li>
021: <mt:ArchiveListFooter>
022: </ul>
023: </li>
024: </ul>
025: </div>
026:</div>
027: </mt:ArchiveListFooter>
028: </mt:ArchiveList>
029:</mt:IfArchiveTypeEnabled>
P.513
●日別アーカイブで月別に日を並べ替える
「日別アーカイブ」ウィジェットテンプレート
<mt:ifArchiveTypeEnabled archive_type="Daily">
<dt class="sidetitle">日別アーカイブ一覧</dt>
<dd class="side">
<mt:archiveList archive_type="Daily" sort_order="descend">
<mt:archiveListHeader>
<ul>
<li><mt:archiveDate format="%Y年%B月" />
<ul>
<mt:archiveDate format="%Y年%B月" setvar="year" />
</mt:archiveListHeader>
<mt:archiveDate format="%Y年%B月" setvar="current_year_month" />
<mt:if name="year_month" ne="$current_year_month">
</ul>
</li>
<li><mt:getVar name="current_year_month" />
<ul>
</mt:if>
<mt:getVar name="current_year_month" setvar="year_month" />
<li><a href="<mt:archiveLink />"><mt:archiveTitle regex_replace="/\d+年\d+月/","" /></a> [<mt:archiveCount />]</li>
<mt:archiveListFooter>
</ul>
</li>
</ul>
</mt:archiveListFooter>
</mt:archiveList>
</dd>
</mt:ifArchiveTypeEnabled>
P.514
●(X)HTMLの埋め込み方法
月別アーカイブの順不同リスト部分の(X)HTMLマークアップ
<ul> ←006
<li>2009年 ←007
<ul> ←008
<li>3月</li> ←019
</ul> ←013
</li> ←014
<li>2008年 ←015
<ul> ←016
<li>10月</li> ←019
<li>8月</li> ←019
</ul> ←021
</li> ←022
</ul> ←023
P.515
●(X)HTMLを定義リストでマークアップする
「月別アーカイブ」ウィジェットテンプレート
<mt:ifArchiveTypeEnabled archive_type="Monthly">
<dt class="sidetitle">月別アーカイブ一覧</dt>
<dd class="side">
<mt:archiveList archive_type="Monthly" sort_order="descend">
<mt:archiveListHeader>
<dl>
<dt><mt:archiveDate format="%Y年" /></dt>
<dd>
<ul>
<mt:archiveDate format="%Y年" setvar="year" />
</mt:archiveListHeader>
<mt:archiveDate format="%Y年" setvar="current_year" />
<mt:if name="current_year" ne="$year">
</ul>
</dd>
<dt><mt:getVar name="current_year" /></dt>
<dd>
<ul>
</mt:if>
<mt:getVar name="current_year" setvar="year" />
<li><a href="<mt:archiveLink />"><mt:archiveTitle regex_replace="/\d+年/","" /></a> [<mt:archiveCount />]</li>
<mt:archiveListFooter>
</ul>
</dd>
</dl>
</mt:archiveListFooter>
</mt:archiveList>
</dd>
</mt:ifArchiveTypeEnabled>
年別の見出しを昇順、月を昇順に表示する
...前略...
<mt:archiveList archive_type="Monthly" sort_order="ascend">
...後略...
P.516
年別の見出しを降順、月を昇順に表示する
●テンプレートをカスタマイズする
「月別アーカイブ」ウィジェットテンプレート(サンプルテンプレート)
<mt:ifArchiveTypeEnabled archive_type="Monthly">
<dt class="sidetitle">月別アーカイブ一覧</dt>
<dd class="side">
<mt:archiveList archive_type="Monthly" sort_order="descend">
<mt:archiveListHeader>
<ul>
<li><mt:archiveDate format="%Y年" />
<ul>
<mt:archiveDate format="%Y年" setvar="year" />
</mt:archiveListHeader>
<mt:archiveDate format="%Y年" setvar="current_year" />
<mt:if name="current_year" ne="$year">
<mt:getVar name="monthly_list" />
</ul>
</li>
<li><mt:getVar name="current_year" />
<ul>
<mt:setVar name="monthly_list" value="" />
</mt:if>
<mt:setVarBlock name="monthly_list" prepend="1">
<li><a href="<mt:archiveLink />"><mt:archiveTitle regex_replace="/\d+年/","" /></a> [<mt:archiveCount />]</li>
</mt:setVarBlock>
<mt:if name="__last__">
<mt:getVar name="monthly_list" />
<mt:else>
<mt:getVar name="current_year" setvar="year" />
</mt:if>
<mt:archiveListFooter>
</ul>
</li>
</ul>
</mt:archiveListFooter>
</mt:archiveList>
</dd>
</mt:ifArchiveTypeEnabled>
★「月別アーカイブ」ウィジェットテンプレート(デフォルトテンプレート)
元のテンプレートから、008~031の構造を大きく変更しています。処理の流れはサンプルテンプレートと同じです。
001:<mt:IfArchiveTypeEnabled archive_type="Monthly">
002: <mt:ArchiveList archive_type="Monthly" sort_order="descend">
003: <mt:ArchiveListHeader>
004:<div class="widget-archive-monthly widget-archive widget">
005: <h3 class="widget-header"><mt:archiveTypeLabel /> <a href="<mt:link template="archive_index" />">アーカイブ</a></h3>
006: <div class="widget-content">
007: <ul class="widget-list">
008: <li class="widget-list-item"><mt:archiveDate format="%Y年" />
009: <ul class="widget-list">
010: <mt:archiveDate format="%Y年" setvar="year" />
011: </mt:ArchiveListHeader>
012: <mt:archiveDate format="%Y年" setvar="current_year" />
013: <mt:if name="current_year" ne="$year">
014: <mt:getVar name="monthly_list" />
015: </ul>
016: </li>
017: <li><mt:getVar name="current_year" />
018: <ul class="widget-list">
019: <mt:setVar name="monthly_list" value="" />
020: </mt:if>
021: <mt:setVarBlock name="monthly_list" prepend="1">
022: <li class="widget-list-item"><a href="<$mt:ArchiveLink$>"><$mt:ArchiveTitle regex_replace="/\d+年/",""$> (<$mt:ArchiveCount$>)</a></li>
023: </mt:setVarBlock>
024: <mt:if name="__last__">
025: <mt:getVar name="monthly_list" />
026: <mt:else>
027: <mt:getVar name="current_year" setvar="year" />
028: </mt:if>
029: <mt:ArchiveListFooter>
030: </ul>
031: </li>
032: </ul>
033: </div>
034:</div>
035: </mt:ArchiveListFooter>
036: </mt:ArchiveList>
037:</mt:IfArchiveTypeEnabled>
P.518
●日別アーカイブで月別に日を並べ替える
「日別アーカイブ」ウィジェットテンプレート
<mt:ifArchiveTypeEnabled archive_type="Daily">
<dt class="sidetitle">日別アーカイブ一覧</dt>
<dd class="side">
<mt:archiveList archive_type="Daily" sort_order="descend">
<mt:archiveListHeader>
<ul>
<li><mt:archiveDate format="%Y年%B月" />
<ul>
<mt:archiveDate format="%Y年%B月" setvar="year_month" />
</mt:archiveListHeader>
<mt:archiveDate format="%Y年%B月" setvar="current_year_month" />
<mt:if name="current_year_month" ne="$year_month">
<mt:getVar name="monthly_list" />
</ul>
<li><mt:getVar name="current_year_month" />
<ul>
<mt:setVar name="monthly_list" value="" />
</mt:if>
<mt:setVarBlock name="monthly_list" prepend="1">
<li><a href="<mt:archiveLink />"><mt:archiveTitle regex_replace="/\d+年\d+月/","" /></a> [<mt:archiveCount />]</li>
</mt:setVarBlock>
<mt:if name="__last__">
<mt:getVar name="monthly_list" />
<mt:else>
<mt:getVar name="current_year_month" setvar="year_month" />
</mt:if>
<mt:archiveListFooter>
</ul>
</li>
</ul>
</mt:archiveListFooter>
</mt:archiveList>
</dd>
年別の見出しを昇順、月を降順に表示する
<mt:archiveList archive_type="Monthly" sort_order="ascend">