6.26 カテゴリ一覧のブログ記事数にサブカテゴリのブログ記事数を含めて表示する ★
P.501
サブカテゴリのブログ記事数との合計を表示する
●テンプレートをカスタマイズする
「カテゴリアーカイブ」ウィジェットテンプレート(サンプルテンプレート)
<mt:ifArchiveTypeEnabled archive_type="Category">
<mt:if tag="blogCategoryCount">
<dt class="sidetitle">カテゴリ一覧</dt>
<dd class="side">
<div id="categories">
<mt:topLevelCategories>
<mt:subCatIsFirst><ul></mt:subCatIsFirst>
<mt:if tag="categoryCount">
<mt:hasSubCategories>
<mt:entriesWithSubCategories>
<mt:entriesFooter>
<mt:getVar name="__counter__" setvar="all_entry_count" />
</mt:entriesFooter>
</mt:entriesWithSubCategories>
</mt:hasSubCategories>
<li><a href="<mt:categoryArchiveLink />" title="<mt:categoryDescription />"><mt:categoryLabel></a> <mt:hasSubCategories><mt:if name="all_entry_count">[<mt:getVar name="all_entry_count" />]</mt:if><mt:else>[<mt:categoryCount />]</mt:hasSubCategories>
<mt:else>
<li><mt:categoryLabel>
</mt:if>
<mt:subCatsRecurse />
</li>
<mt:subCatIsLast></ul></mt:subCatIsLast>
</mt:topLevelCategories>
</div>
</dd>
</mt:if>
</mt:ifArchiveTypeEnabled>
★「カテゴリアーカイブ」ウィジェットテンプレート(デフォルトテンプレート)
デフォルトテンプレートの場合、元のテンプレートに010~016を追加し、017を変更しています。処理の流れはサンプルテンプレートと同じです。
001:<mt:IfArchiveTypeEnabled archive_type="Category">
002:<div class="widget-archive widget-archive-category widget">
003: <h3 class="widget-header">カテゴリ</h3>
004: <div class="widget-content">
005: <mt:TopLevelCategories>
006: <mt:SubCatIsFirst>
007: <ul class="widget-list">
008: </mt:SubCatIsFirst>
009: <mt:IfNonZero tag="mt:CategoryCount">
010: <mt:hasSubCategories>
011: <mt:entriesWithSubCategories>
012: <mt:entriesFooter>
013: <mt:getVar name="__counter__" setvar="all_entry_count" />
014: </mt:entriesFooter>
015: </mt:entriesWithSubCategories>
016: </mt:hasSubCategories>
017: <li class="widget-list-item"><a href="<mt:categoryArchiveLink />" title="<mt:categoryDescription />"><mt:categoryLabel></a> <mt:hasSubCategories><mt:if name="all_entry_count">[<mt:getVar name="all_entry_count" />]</mt:if><mt:else>[<mt:categoryCount />]</mt:hasSubCategories>
018: <mt:Else>
019: <li class="widget-list-item"><$mt:CategoryLabel$>
020: </mt:IfNonZero>
021: <$mt:SubCatsRecurse$>
022: </li>
023: <mt:SubCatIsLast>
024: </ul>
025: </mt:SubCatIsLast>
026: </mt:TopLevelCategories>
027: </div>
028:</div>
029:</mt:IfArchiveTypeEnabled>
P.502
サブカテゴリのブログ記事数と別に表示
●テンプレートをカスタマイズする
「カテゴリアーカイブ」ウィジェットテンプレート(サンプルテンプレート)
...前略...
<li><a href="<mt:categoryArchiveLink />" title="<mt:categoryDescription />"><mt:categoryLabel></a> <mt:hasSubCategories><mt:if name="all_entry_count"><mt:categoryCount setVar="category_count" />[<mt:categoryCount />](<mt:getVar name="all_entry_count" op="-" value="$category_count" />)</mt:if><mt:else>[<mt:categoryCount />]</mt:hasSubCategories>
...後略...
★「カテゴリアーカイブ」ウィジェットテンプレート(デフォルトテンプレート)
デフォルトテンプレートの場合、「親カテゴリのブログ記事数との合計を表示する」のデフォルトテンプレートの017を、次のようにカスタマイズします。
処理の流れはサンプルテンプレートと同じです。
...前略...
<li class="widget-list-item"><a href="<mt:categoryArchiveLink />" title="<mt:categoryDescription />"><mt:categoryLabel></a> <mt:hasSubCategories><mt:if name="all_entry_count"><mt:categoryCount setVar="category_count" />[<mt:categoryCount />](<mt:getVar name="all_entry_count" op="-" value="$category_count" />)</mt:if><mt:else>[<mt:categoryCount />]</mt:hasSubCategories>
...後略...