题目:在运用dedecms的文档关键词替代功用时,会形成交织替代
如:
长尾关键词1:男子喝金丝皇菊有什么优点?
长尾关键词2:喝金丝皇菊有什么优点?
主关键词3:金丝皇菊
运用体系默许的功用时,在替代主关键词的时刻,会将上面已替代好的长尾关键词中的“金丝皇菊”也替代掉,从而破坏了原有的长尾关键词锚文本。
处理思绪:
1.先将要替代的关键词替代成相似:
关键词1:'#####0#####'
关键词2:'#####2#####'
关键词3:'#####3#####'
再举行以上替代操纵的时刻,我们须要保留关键词所对应的锚文本,如:
'#####0#####' --> 关键词1的锚文本
'#####1#####' --> 关键词2的锚文本
'#####2#####' --> 关键词3的锚文本
等悉数替代终了后,我们末了再恢复返来
这里,我们重要修正:include/arc.archives.class.php 文件
修正部份以下:
//高亮专用, 替代屡次是能够不能到达最屡次 function _highlight($string, $words, $result, $pre) { global $cfg_replace_num; // if (version_compare(PHP_VERSION, '5.5.0', '>=')) // { // $string = $string[0]; // $pre = $pre[0]; // } //修正 Start $replaced_array = array(); $replaced_tiems = 0; //修正 End $string = str_replace('\"', '"', $string); if ($cfg_replace_num > 0) { foreach ($words as $key => $word) { if ($GLOBALS['replaced'][$word] == 1) { continue; } //修正 Start $replace_string = '#####' . $replaced_tiems . '#####'; $replaced_array[$replace_string] = $result[$key]; $string = preg_replace("#" . preg_quote($word) . "#", $replace_string, $string, $cfg_replace_num); $replaced_tiems+= 1; //修正 End // $string = preg_replace("#".preg_quote($word)."#", $result[$key], $string, $cfg_replace_num); if (strpos($string, $word) !== FALSE) { $GLOBALS['replaced'][$word] = 1; } } //修正 Start foreach ($replaced_array as $k => $v) { $string = str_ireplace($k, $v, $string); } //修正 End } else { $string = str_replace($words, $result, $string); } return $pre . $string; }
注重:这里我们须要在背景修正文档关键词的频次,默许是 频次高的优先替代,频次低的后替代
相干教程:PHP视频教程
以上就是dedecms关键词替代计划的细致内容,更多请关注ki4网别的相干文章!