この記事の概要
- 投稿日:
- 2003年 12月 11日
- 投稿者:
- yu
- カテゴリー:
- Tips
- タグ:
nucleusはblogを複数運用していても、記事に割り振られるidが重複することがないので、ある記事を別のblogへ移動させても記事そのものへのリンクは不変です(permlinkなどと呼ばれるようです)。
しかしblogをそれぞれ異なるディレクトリに展開していると、ある記事を別のblogへ移動させた場合、引越し先のblog(とシステムを含むディレクトリ)からしかアクセス出来なくなってしまいます。それの対応策。
たとえばこんな例
'nucleus' blogにある記事(id27)
http://datoka.jp/nucleus/index.php?itemid=27
'index' blogに記事を移動させると、今までのURLは・・・
http://datoka.jp/nucleus/index.php?itemid=27 →無効
移動先はもちろんOK。システムを含むディレクトリ(ここでは'blog'にシステムファイルを置いてるとする)も大丈夫。
http://datoka.jp/index/index.php?itemid=27 http://datoka.jp/blog/index.php?itemid=27
これを、
http://datoka.jp/nucleus/index.php?itemid=27 →こちらも従来どおり有効
にさせるためのちょっとしたハック。
有効といっても、実際は水面下でシステムがリンク切れを検知し、引越し先のURLへ自動的に飛ばしてくれるというものです。
変更箇所
/nucleus/libs/globalfunctions.php
selector ファンクション内(450行あたり 2.5cvs ja 01/15では470行)
変更前:
// if a different blog id has been set through the request or selectBlog(),
// deny access
if ($blogid && (intval($blogid) != $obj->iblog))
doError(_ERROR_NOSUCHITEM);
変更後:
// if a different blog id has been set through the request or selectBlog(),
// jump to correct url
if ($blogid && (intval($blogid) != $obj->iblog)) {
if (!headers_sent()) {
$b =& $manager->getBlog($obj->iblog);
$correctURL = $b->getURL();
header('Location: ' . $correctURL . '?itemid=' . $itemid);
exit;
}
else doError(_ERROR_NOSUCHITEM);
}