XOOPS?に検索語マーカーを †
Googleのキャッシュページなどでおなじみの検索語マーカー。
検索した語をハイライト表示するあれを、XOOPS?に導入してみよう!
必要なファイル †
&ref(): File not found: "getengine.inc.php" at page "検索後マーカー";- &ref(): File not found: "getengine_0.inc.php" at page "検索後マーカー";
- 修正点(ダウンロード後 getengine.inc.phpにリネームすること)
- モジュールの出力がない場合は処理しない。
- $xoopsConfig から日本語使用情報を取得
- mb_convert_kana が使えない環境でもエラーが出ないように
- 修正点(ダウンロード後 getengine.inc.phpにリネームすること)
- &ref(): File not found: "search_engines.dat" at page "検索後マーカー";
これら2つのファイルを XOOPS?_ROOT_PATH/include/ にアップロードしてください。
XOOPS?ファイルの変更 †
*XOOPS?_ROOT_PATH/include/common.php †
// ############## Include common functions file ##############
の上に以下を挿入
include_once XOOPS_ROOT_PATH.'/include/getengine.inc.php'; list($getengine_name,$getengine_query)=xoops_se_getengine(); define("XOOPS_QUERY_WORD",$getengine_query); define("XOOPS_SEARCH_ENGINE_NAME",$getengine_name); unset ($getengine_name,$getengine_query);
*XOOPS?_ROOT_PATH/footer.php †
include_once XOOPS_ROOT_PATH . '/include/notification_select.php'; if (isset($xoopsOption['template_main'])) { if (isset($xoopsCachedTemplateId?)) { $xoopsTpl->assign('xoops_contents', $xoopsTpl->fetch('db:'.$xoopsOption['template_main'], $xoopsCachedTemplateId?)); } else { $xoopsTpl->assign('xoops_contents', $xoopsTpl->fetch('db:'.$xoopsOption['template_main'])); } } else { if (isset($xoopsCachedTemplate?)) { $xoopsTpl->assign('dummy_content', ob_get_contents()); $xoopsTpl->assign('xoops_contents', $xoopsTpl->fetch($xoopsCachedTemplate?, $xoopsCachedTemplateId?),); } else { $xoopsTpl->assign('xoops_contents', ob_get_contents()); } ob_end_clean(); }
を以下のように変更
include_once XOOPS_ROOT_PATH . '/include/notification_select.php'; if (isset($xoopsOption['template_main'])) { if (isset($xoopsCachedTemplateId?)) { $xoopsTpl->assign('xoops_contents', xoops_word_highlight($xoopsTpl->fetch('db:'.$xoopsOption['template_main'], $xoopsCachedTemplateId?),XOOPS_QUERY_WORD)); } else { $xoopsTpl->assign('xoops_contents', xoops_word_highlight($xoopsTpl->fetch('db:'.$xoopsOption['template_main']),XOOPS_QUERY_WORD)); } } else { if (isset($xoopsCachedTemplate?)) { $xoopsTpl->assign('dummy_content', ob_get_contents()); $xoopsTpl->assign('xoops_contents', xoops_word_highlight($xoopsTpl->fetch($xoopsCachedTemplate?, $xoopsCachedTemplateId?),XOOPS_QUERY_WORD)); } else { $xoopsTpl->assign('xoops_contents', xoops_word_highlight(ob_get_contents(),XOOPS_QUERY_WORD)); } ob_end_clean(); }
*XOOPS?_ROOT_PATH/xoops.css †
以下のスタイルを追加。
strong.word0 { background-color:#FFFF66; color:black; }
strong.word1 { background-color:#A0FFFF; color:black; }
strong.word2 { background-color:#99FF99; color:black; }
strong.word3 { background-color:#FF9999; color:black; }
strong.word4 { background-color:#FF66FF; color:black; }
strong.word5 { background-color:#880000; color:white; }
strong.word6 { background-color:#00AA00; color:white; }
strong.word7 { background-color:#886800; color:white; }
strong.word8 { background-color:#004699; color:white; }
strong.word9 { background-color:#990099; color:white; }
以上で、検索エンジンから飛んできた場合と、XOOPS?の検索で検索した場合に、各モジュールの出力部分の該当キーワードがハイライト表示されます。
この機能は、PukiWiki 1.4 のコードと PHP-STAT Pro のコードを寄せ集めて実現しています。
各開発者の方に感謝・感謝
Last-modified: Tue, 19 Jul 2005 18:24:48 JST (6533d)