概要
カスタムフィールドに値がなかった場合、すべての表示を非表示にする処理を書いてみた。
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>