トップ  »  Movable Type  »  MTSetVarBlockとMTIf~likeを使いこなす

2008年10月14日

MTSetVarBlockとMTIf~likeを使いこなす

使える条件分岐


<MTSetVarBlock name="outputstate"><MToutput></MTSetVarBlock>
<MTIf name="outputstate" like="出力する">
<mt:Entries lastn="15">
~
</MTIf>
</mt:Entries>

最新の年度情報をだす


<MTSetVarBlock name="thisYear"><mt:Entries lastn="1"><mt:entryDate format="%Y" /></mt:Entries></MTSetVarBlock>

<div id="pressRelease">
<table class="newsTable">
<mt:Entries category="プレスリリース">
<mt:SetVarBlock name="setYear"><$mt:EntryDate format="%Y"$></mt:SetVarBlock>
<mt:If name="setYear" like="$thisYear">
<tr><th><mt:EntryDate format="%Y.%m.%d" /></th><td><img src="/news/images/index_ico02.gif" width="72" height="17" alt="プレスリリース" /><a href="<mt:EntryLink />"><mt:EntryTitle /></a></td></tr>
</mt:If>
</mt:Entries>
</table>
</div><!-- /pressRelease -->

○○○○年の年をとる


<mt:ArchiveTitle regex_replace="/&#24180;/","" />

カスタムフィールドを利用して、urlを入力すると記事のタイトルに他のサイトにリンクをはる。(別窓でも表紙可能)


<mt:If tag="link"> //mt:linkはカスタムフィールドで追加したタグ
<a href="<mt:link />" <mt:IfNonZero tag="target">target="_blank"</mt:IfNonZero>/><mt:EntryTitle /></a> //targetはカスタムフィールドで追加したタグ
<mt:else>
<a href="<mt:EntryLink />"><mt:EntryTitle /></a>
</mt:If>

トラックバック(0)

このブログ記事を参照しているブログ一覧: MTSetVarBlockとMTIf~likeを使いこなす

このブログ記事に対するトラックバックURL: http://magic-happens.net/mt/mt-tb.cgi/39

コメントする

Top of Pageページの先頭へ

© Magic Happens