ソース
<mt:setvarblock name="3ten_flag"><$mt:entrybody strip_linefeeds="1" remove_html="1" count_characters="1" $></mt:setvarblock>
<mt:if name="3ten_flag" gt="200">
<$mt:entrybody strip_linefeeds="1" remove_html="1" trim_to="200"$>...
<mt:else>
<$mt:entrybody strip_linefeeds="1" remove_html="1"$>
</mt:if>
<mt:if name="3ten_flag" gt="200">
<$mt:entrybody strip_linefeeds="1" remove_html="1" trim_to="200"$>...
<mt:else>
<$mt:entrybody strip_linefeeds="1" remove_html="1"$>
</mt:if>
解説
- まず、setvarblockにentrybodyの値を覚えさせます。
3ten_flagが今回のsetvarblockの名前ですね。
<$mt:entrybody strip_linefeeds="1" remove_html="1" count_characters="1"$>
□次のグローバル・モディファイアを利用します。
strip_linefeeds="1" http://p.tl/DCMH
remove_html="1" http://p.tl/fFpA
count_characters="1" http://p.tl/fFpA
strip_linefeedsは改行コードを除去します。
remove_htmlはhtmlタグを除去します。
count_charactersは文字数をカウントします。
これでentrybodyの値をsetvarblockに代入できました。 - そしてif文。
gt="200" これで200文字より多いならば次の処理をしなさい。という命令文が作れます。
あとは...を付けたいentrybodyに対してtrim_to="200"で文字数調整をして、elseで...なしの処理を行うだけ!