【MovableType】カスタムフィールドを使った記事の抽出

電脳備忘録

久しぶりに仕事でMovableTypeをいじりました。WordPressとごっちゃにならないように、気を付けないとなぁ...。
それはさておき、カスタムフィールドでチェックボックスにチェックされたエントリーを新しいものから5件抽出し、 それ以外のエントリーを一覧で表示したいという要望があったのでこんな感じで対応。

まんまやりたいことがMovableTypeのドキュメントサイトに掲載されていたので助かりました。

MTEntries

テンプレートタグリファレンス
<section>
<h1>お勧めエントリー</h1>
<mt:Entries field:pickup_entry="1" limit="5" sort_by="authored_on" sort_order="descend">
<$mt:Include module="ブログ記事の概要"$>
</mt:Entries>
</section>
<section>
<h1>エントリー一覧</h1>
<MTEntries unique="1">
<$mt:Include module="ブログ記事の概要"$>
</MTEntries>
</section>
field:pickup_entry="1"
カスタムフィールドで設定したチェックボックス「pickup_entry」にチェックが入っている記事
limit="5"
5件を上限
sort_by="authored_on"
公開日を基準
sort_order="descend"
降順で並べる
unique="1"
同じテンプレート内で使用した MTEntries ブロックで出力したブログ記事を除いて出力。

ページ分割プラグイン「PageBute」を使ってみました。

<section>
<h1>お勧めエントリー</h1>
<MTPageContents count="10">
<mt:Entries field:pickup_entry="1" limit="5" sort_by="authored_on" sort_order="descend">
<$mt:Include module="ブログ記事の概要"$>
</mt:Entries>
</section>
<section>
<h1>エントリー一覧</h1>
<MTEntries unique="1">
<$mt:Include module="ブログ記事の概要"$>
<$MTPageSeparator$>
</MTEntries>
</MTPageContents>
</section>
<div class="pagenate">
<ul>
<MTIfPageBefore>
<$MTPageBefore delim="前の10件"$>
</MTIfPageBefore>
<$MTPageLists link_start="<li>" link_close="</li>"$>
<MTIfPageNext>
<$MTPageNext delim="次の10件"$>
</MTIfPageNext>
</ul>
</div>

うん、とくに問題ないみたい。

広告

ブログの維持費に充てるでございます・・・。