ドメイン変更やXOOPSインストール先の階層変更等でXOOPS_URLを変更することがあります。
そんなときにDBに保存されてるコンテンツのURLもダンプデータを一括置換等するのですが、いろいろ事情があってダンプデータの置換ができないときにhtmlの置換preloadでしのいだことがあります。
仕組みとしてはSmartyのOutputフィルタプラグインを使ってるだけです。
XOOPS_ROOT_PATH/preload/htmlReplace.class.php
<?php
if (!defined('XOOPS_ROOT_PATH')) exit();
class htmlReplace extends XCube_ActionFilter
{
function preFilter()
{
$this->mRoot->mDelegateManager->add('XoopsTpl.New', array( &$this , 'xoopsTplHook' ) ) ;
}
function xoopsTplHook( &$xoopsTpl )
{
$xoopsTpl->register_outputfilter("htmlReplaceFilter");
}
}
function htmlReplaceFilter($tpl_output, &$smarty)
{
// ここで置換
$replaced = preg_replace('/http:\/\/old_domain\.com/', 'https://new_domain.com', $tpl_output);
return $replaced;
}