網站在替換關鍵的時候總是會出現錯誤,就像是dede和dede中國網在替換的時候鏈接就會出現錯誤,所以想要一次性的替換所有的關鍵詞就造成了很大的困難。
解決DedeCMS一次性替換所有文章關鍵詞的具體方法:
打開include/arc.archives.class.php
在1226行代碼,找到以下代碼:
//高亮專用, 替換多次是可能不能達到最多次
function _highlight($string, $words, $result, $pre)
{
global $cfg_replace_num;
$string = str_replace('"', '"', $string);
后面增加一段代碼,使它變為
//高亮專用, 替換多次是可能不能達到最多次
function _highlight($string, $words, $result, $pre)
{
global $cfg_replace_num;
$string = str_replace('"', '"', $string);
uasort($words,create_function('$a, $b','return strlen($a)>strlen($b);'));
這樣就可以讓關鍵詞從字節比較小的開始替換,這樣就不會出現上面說的替換錯誤了。