相信經(jīng)常使用dedecms的朋友遇到過(guò)這樣的問(wèn)題。例如,我在文檔關(guān)鍵詞中設(shè)置錨文本鏈接的時(shí)候,“站長(zhǎng)基地”與“站長(zhǎng)”同時(shí)都指向于http://www.genban.org。當(dāng)文檔中出現(xiàn)站長(zhǎng)基地的時(shí)候,這時(shí)只有“站長(zhǎng)”含有鏈接,而我們希望的則是“站長(zhǎng)基地”帶有鏈接,那么如何解決呢?教程如下:
解決方法(先備份)
第一步:打開(kāi)目錄include中的arc.archivew.class.php
找到以下代碼:
- function ReplaceKeyword($kw,&$body)
從這里然后一直到最下面。替換這段代碼:
- function ReplaceKeyword($kw,&$body)
- {
- global $cfg_cmspath;
- $maxkey = 5;
- $kws = explode(",",trim($kw)); //以分好為間隔符
- $i=0;
- $karr = $kaarr = $GLOBALS['replaced'] = array();
- //暫時(shí)屏蔽超鏈接
- $body = preg_replace("/(<a(.*))(>)(.*)(<)(/a>)/isU", '1-]-4-[-6', $body);
- global $dsql;
- $query="SELECT * FROM dede_keywords WHERE rpurl<>'' and sta=1 ORDER BY length(keyword)desc";
- $dsql->SetQuery($query);
- $dsql->Execute();
- while($row = $dsql->GetArray())
- {
- $key = trim($row['keyword']);
- $key_url=trim($row['rpurl']);
- $karr[] = $key;
- $kaarr[] = "<u><a href='$key_url' target='_blank'>$key</a></u>";
- }
- foreach ($karr as $key => $word)
- {
- $body = preg_replace("/(^|>)([^<]+)(?=<|$)/sUe", "_highlight('2', $karr[$key], $kaarr[$key], '1')", $body);
- //echo $body."<br/>";
- //恢復(fù)超鏈接
- $body = preg_replace("/(<a(.*))-]-(.*)-[-(/a>)/isU", '1>3<4', $body);
- //暫時(shí)屏蔽超鏈接
- $body = preg_replace("/(<a(.*))(>)(.*)(<)(/a>)/isU", '1-]-4-[-6', $body);
- }
- //恢復(fù)超鏈接
- $body = preg_replace("/(<a(.*))-]-(.*)-[-(/a>)/isU", '1>3<4', $body);
- return $body;
- }
- }//End Archives
- //高亮專用, 替換多次是可能不能達(dá)到最多次
- function _highlight($string, $words, $result, $pre)
- {
- global $cfg_replace_num;
- $string = str_replace('"', '"', $string);
- if($GLOBALS['replaced'][$words] == 1)
- {
- return $pre.$string;
- }
- if($cfg_replace_num > 0)
- {
- $string = preg_replace("/".preg_quote($words)."/", $result, $string, $cfg_replace_num);
- if(strpos($string, $words) !== false)
- {
- $GLOBALS['replaced'][$words] = 1;
- //echo $words;
- }
- }
- else
- {
- $string = str_replace($words, $result, $string);
- }
- return $pre.$string;
- }
進(jìn)入后臺(tái)生成,至此大功告成。
DEDECMS文檔關(guān)鍵詞維護(hù)中的"頻率"是什么意思?
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: DEDECMS文檔關(guān)鍵詞,鏈接重復(fù)的解決辦法