LoginSignup
3
4

More than 5 years have passed since last update.

MovableTypeでカスタムフィールドに値がなかった場合の処理覚書

Last updated at Posted at 2014-02-14

概要

カスタムフィールドに値がなかった場合、すべての表示を非表示にする処理を書いてみた。
SetVarBlockでまずは、カスタムフィールドの値を取得し
モディファイアのeqで値が0だった場合の処理をMT:Ifで条件分岐させてみた。
覚書になります。

追記

MTのバージョン5.02だと、<mt:If tag="">で条件が通らなかったため、上記のような書き方をしました。

最新バージョンだと通常通りに動作しました。
下位バージョンの改修だったりすることがあるので、意外と忘れたりする。

インデックステンプレート

<mt:SetVarBlock name="important"><MTEntries><mt:important></MTEntries></mt:SetVarBlock>
<mt:If name="important" eq="0">
ない場合の処理
<mt:Else>
<MTEntries lastn="2">
    <MTEntriesHeader>
        <div class="conts01">
            <h2>セクションタイトル</h2>
                <div class="newsList">
                    <div class="inner">
                    <table border="0" cellspacing="0" cellpadding="0" class="newsListTbl">
    </MTEntriesHeader>
                    <tr>
                        <th scope="row"><$MTEntryDate format="%Y年%b月%e日"$></th>
                        <td><a href=""><$MTEntryTitle$></a></td>
                    </tr>
    <MTEntriesFooter>
                </table>
            </div>
        </div>
    </div>
    </MTEntriesFooter>
</MTEntries>
</mt:If>
3
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
3
4