LoginSignup
2
7

More than 5 years have passed since last update.

[MovableType]コンテンツタイプでカテゴリセットを使う

Last updated at Posted at 2018-09-13

リファレンスに例が無くハマったのでメモ。

環境

  • Movable Type 7 r4208

コンテンツタイプテンプレートでコンテンツデータに指定したカテゴリの一覧を出力

コンテンツタイプに指定したカテゴリセットのフィールドの名前(カテゴリセットの名前ではなく)を「カテゴリ1」とすると、こんな感じ。

<mt:ContentField content_field="カテゴリ1">
  <!-- mt:Categories とかは無しで直接カテゴリがループする -->
  <!-- 通常のループと同じく、__first__/__last__などが使える -->
  <mt:If name="__first__"><ul></mt:If>
  <!-- 通常のカテゴリーと同じテンプレート変数が使える -->
  <li><$mt:CategoryBasename$>: <$mt:CategoryLabel$></li>
  <mt:If name="__last__"></ul></mt:If>
<mt:Else>
  <!-- 他カテゴリと同様に、カテゴリの指定が無い場合は mt:Else が機能する -->
  <li>なし</li>
</mt:ContentField>

一番最初にメインカテゴリが来るので、それだけ必要な場合は__first__で取ってくると良いかも。

特定のカテゴリセットに属するコンテンツデータを一覧する

<mt:Contents content_type="コンテンツタイプ1" field:6ab81edd42c2bd6841a671c71d28132c847b9dac="カテゴリ1 AND NOT カテゴリ2">
  <mt:ContentsHeader></ul></mt:ContentsHeader>
  <li><$mt:ContentIdentifier$>: <mt:ContentField content_field="フィールド1"><$mt:ContentFieldValue$></mt:ContentField></li>
  <mt:ContentsFooter></ul></mt:ContentsFooter>
</mt:Contents>

ちなみにこのバージョンでは、カテゴリでコンテンツデータを絞り込むと、並べ替えが効かないバグがある。

2
7
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
7