MT 4.0 に上げてから、月別アーカイブなどで使用している MTEntriesタグでsort_order="ascend"が効かなくなった。
いろいろ調べてみたら、sort_byとか言う属性もあるようなので指定してみたけど変わらず。
結局、ソースを追いかけたらどうもMTのバグらしい。
lib/MT/Template/ContextHandlers.pm に以下のパッチをあてたら、無事にsort_order="ascend"が効くようになった。
どうも、perlの$と@と%と#と\の関係が良くわかってないので、デバッグにも苦労する。
いろいろ調べてみたら、sort_byとか言う属性もあるようなので指定してみたけど変わらず。
結局、ソースを追いかけたらどうもMTのバグらしい。
lib/MT/Template/ContextHandlers.pm に以下のパッチをあてたら、無事にsort_order="ascend"が効くようになった。
どうも、perlの$と@と%と#と\の関係が良くわかってないので、デバッグにも苦労する。
*** ContextHandlers.pm.ORIG 2007-08-04 06:20:03.000000000 +0900
--- ContextHandlers.pm 2007-08-21 00:04:34.000000000 +0900
***************
*** 2917,2929 ****
if ( $col ne 'score' ) {
if (my $def = $class->column_def($col)) {
if ($def->{type} =~ m/^integer|float$/) {
! @entries = $so eq 'ascend' ?
! sort { $a->$col() <=> $b->$col() } @entries :
! sort { $b->$col() <=> $a->$col() } @entries;
} else {
! @entries = $so eq 'ascend' ?
! sort { $a->$col() cmp $b->$col() } @entries :
! sort { $b->$col() cmp $a->$col() } @entries;
}
$no_resort = 1;
}
--- 2917,2929 ----
if ( $col ne 'score' ) {
if (my $def = $class->column_def($col)) {
if ($def->{type} =~ m/^integer|float$/) {
! @$entries = $so eq 'ascend' ?
! sort { $a->$col() <=> $b->$col() } @$entries :
! sort { $b->$col() <=> $a->$col() } @$entries;
} else {
! @$entries = $so eq 'ascend' ?
! sort { $a->$col() cmp $b->$col() } @$entries :
! sort { $b->$col() cmp $a->$col() } @$entries;
}
$no_resort = 1;
}
カテゴリ
MovableTypeトラックバック(2)
このブログ記事を参照しているブログ一覧: MT 4.0 の MTEntries で sort_orderがきかない
このブログ記事に対するトラックバックURL: https://www.wizard-limit.net/cgi-bin/mt/mt-tb.cgi/1193
» MT4.0アップグレード検証(テンプレート動作)(MT Issues on X-Logicブログ)~のトラックバック
前回の記事で書いたアップグレード作業で、MT環境(ファイルシステムとDB)はMT... 続きを読む
» MT 4.0のMTEntriesでsort_orderがきかない(Hori's Weblog)~のトラックバック
MT4.0でバグがあるらしいです。 ContextHandlers.pmの2917~2929行目を書... 続きを読む

コメントする