首先需要调整搜索页面的一个栏目关键词替换,找到/plus/search.php将其中58行代码:
<pre class="brush:php;"> foreach($typeArr as $id=>$typename) { $keywordn = str_replace($typename, ' ', $keyword); if($keyword != $keywordn) {
修改为:
foreach($typeArr as $id=>$typename)
{
//$keywordn = str_replace($typename, ' ', $keyword);
$keywordn = $keyword;
if($keyword != $keywordn)
{
然后,我们再调整下分词检索的类,找到/include/arc.searchview.class.php,
找到function GetKeywords($keyword)这个类的方法,替换为:
function GetKeywords($keyword)
{
global $cfg_soft_lang;
$keyword = cn_substr($keyword, 50);
$row = $this->dsql->GetOne("SELECT spwords FROM `dede_search_keywords` WHERE keyword='
".addslashes($keyword)."'; ");
if(!is_array($row))
{
if(strlen($keyword)>7)
{
$sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
$sp->SetSource($keyword, $cfg_soft_lang, $cfg_soft_lang);
$sp->SetResultType(2);
$sp->StartAnalysis(TRUE);
$keywords = $sp->GetFinallyResult();
$idx_keywords = $sp->GetFinallyIndex();
ksort($idx_keywords);
$keywords = $keyword.' ';
foreach ($idx_keywords as $key => $value) {
if (strlen($key) <= 3) {
continue;
}
$keywords .= ' '.$key;
}
$keywords = preg_replace("/[ ]{1,}/", " ", $keywords);
//var_dump($idx_keywords);exit();
unset($sp);
}
else
{
$keywords = $keyword;
}
$inquery = "INSERT INTO `dede_search_keywords`(`keyword`,`spwords`,`count`,`result`,`lasttime`)
VALUES ('".addslashes($keyword)."', '".addslashes($keywords)."', '1', '0', '".time()."'); ";
$this->dsql->ExecuteNoneQuery($inquery);
}
else
{
$this->dsql->ExecuteNoneQuery("UPDATE `dede_search_keywords` SET count=count+1,lasttime='
".time()."' WHERE keyword='".addslashes($keyword)."'; ");
$keywords = $row['spwords'];
}
return $keywords;
}
更多信息请查看IT技术专栏