LoginSignup
3
2

More than 5 years have passed since last update.

【Tips】MovableTypeでブログ記事のmt:EntryTagsが他のブログのカテゴリと紐付ける方法

Last updated at Posted at 2016-11-22

忙しいですがメモしないと忘れて書かなくなるので残しておきます。

あまり使うことがないと思うのですが、記事に入力したタグの文字列と他のブログカテゴリ名が一致した記事だけにカテゴリの情報を渡すという方法になります。

  • 他ブログのカテゴリ情報を変数に格納
  • mt:EntryTagsのブロックタグ内のTagNameで条件分岐させる
<mt:Blogs blog_ids="カテゴリ先のあるブログID" ignore_archive_context="1">
<mt:TopLevelCategories>
<$mt:CategoryLabel setvar="cat_label"$>  // 他ブログで使用しているカテゴリラベルを変数に格納
<mt:CategoryArchiveLink setvar="cat_link" />  // 他ブログでのカテゴリリンクを変数に格納
<mt:CategoryDescription setvar="cat_label_description" />  // 他ブログのカテゴリの説明
<mt:EntryTags>
  <mt:If tag="TagName" eq="$cat_label">  // 記事のEntryTagとカテゴリが一致したものを出力
  <h1>他ブログ名</h1>
  <a href="<mt:Var name="cat_link" />">
    <h2><mt:Var name="cat_label" /></h2>
    <p><mt:Var name="cat_label_description" /></p>
  </a>
  </mt:If>
</mt:EntryTags>
</mt:TopLevelCategories>
</mt:Blogs>

たったこれだけですが、何かに紐付けをしたいときには使えるかと思います。

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