2005年11月11日

カテゴリ内の次・前リンク(3.2対応)

以前ご紹介した「カテゴリ内の次・前リンク」の続きです。
MT3.2になったら、MT.pmへこの記述が無くなっていました。
探しましたところ「/lib/MT/WeblogPublisher.pm」に移ってました。

それでは「/lib/MT/WeblogPublisher.pm」のファイルを改造します。
(それ以外の改造については、「カテゴリ内の次・前リンク」を参考にしてください。)

191行目あたりに、下記記述が確認できると思います。
この間に改造部分を入れます。

return 1 unless $param{BuildDependencies} || $param{BuildIndexes} ||
$param{BuildArchives};

if ($param{BuildDependencies}) {
## Rebuild previous and next entry archive pages.
if (my $prev = $entry->previous(1)) {
$mt->rebuild_entry( Entry => $prev ) or return;
}
if (my $next = $entry->next(1)) {
$mt->rebuild_entry( Entry => $next ) or return;
}

return 1 unless $param{BuildDependencies} || $param{BuildIndexes} ||
$param{BuildArchives};
if((defined $MT::Template::Context::Global_handlers{'EntryPreviousInCategory'}->{'is_container'})
&& (defined $MT::Template::Context::Global_handlers{'EntryNextInCategory'}->{'is_container'}))
{
my $cats = $entry->categories;
# previous
for my $cat (@$cats) {
my $prev = $entry->previous(1);
if($prev && !$prev->is_in_category($cat)) {
$prev = $entry->previous(2);
while ($prev && !$prev->is_in_category($cat)){
$prev = $prev->previous(1);
}
if ($prev) {
$mt->_rebuild_entry_archive_type(Entry => $prev,
Blog => $blog,
ArchiveType => 'Individual')
or die $mt->errstr;
}
}
# next
my $next = $entry->next(1);
if($next && !$next->is_in_category($cat)) {
$next = $entry->next(2);
while ($next && !$next->is_in_category($cat)){
$next = $next->next(1);
}
if ($next) {
$mt->_rebuild_entry_archive_type(Entry => $next,
Blog => $blog,
ArchiveType => 'Individual')
or die $mt->errstr;
}
}
}
}

if ($param{BuildDependencies}) {
## Rebuild previous and next entry archive pages.
if (my $prev = $entry->previous(1)) {
$mt->rebuild_entry( Entry => $prev ) or return;
}
if (my $next = $entry->next(1)) {
$mt->rebuild_entry( Entry => $next ) or return;
}

Posted luna : 2005年11月11日 16:21 | カスタマイズ

TrackBackPings

トラックバックを何回もやっても気にしないでいいですよ。こちらで削除しますので。

TrackBack URL>>

カテゴリ内の次・前リンク(3.2対応)へのトラックバック一覧

» MT:同一カテゴリー内で、前後のエントリーにリンクする from ehamono Sakurai's blog(on: 2005年11月22日 18:14)

先日から、娘のバレーボール部のホームページを、MT3で作っていまして、いくつかプ... READ

» カテゴリ内で前・次リンクを行う from 儲け話♪(on: 2005年12月31日 11:48)

MovableType( ムーバブルタイプ )を既にインストールして使われている... READ

Comments




保存しますか?