LoginSignup
2
4

More than 5 years have passed since last update.

Movable Typeで記事のないカテゴリーだけ表示させないようにする

Last updated at Posted at 2014-11-11

記事がないときは、カテゴリを非表示にするという要件があったため、調べてたのメモしておきます。
以下、ソースになります.

<MTTopLevelCategories>
  <MTHasNoParentCategory>
    <mt:SetVarBlock name="cat_cnt"><$MTCategoryCount$></mt:SetVarBlock>
    <MTSetVarBlock name="folder_name"><$MTCategoryLabel$></MTSetVarBlock>
    <mt:If name="cat_cnt" ne="0">
      <$MTCategoryLabel$><-- カテゴリを表示 -->
    </mt:If>
  </MTHasNoParentCategory>
</MTTopLevelCategories>

<$MTCategoryCount$>が0じゃない場合( ne="0")で取得できる

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4