易优cms—安全好用,商用授权只需要188元,网址:https://www.eyoucms.com
相信经常使用dedecms的朋友遇到过这样的问题。例如,我在文档关键词中设置锚文本链接的时候,“站长基地”与“站长”同时都指向于https://www.weimahe.com。当文档中出现站长基地的时候,这时只有“站长”含有链接,而我们希望的则是“站长基地”带有链接,那么如何解决呢?教程如下:
解决方法(先备份)
第一步C F \ [ ) ?:打开目录include中的arc.archivew.class.php
找到以下代码:
- functionReplaceKeyword($kw,&$body)
从这里然后一直到最下面。替换这段代码:
function ReplaceKeyword($kw,&$body) { glo~ % T ] y i # J -bal $cfg_cmspath; $maxkeyD C q + N ] = 5; $kws = explode(",",trim($kw)); //以分好为间隔符 $i=0; $karr = $kaarr = $GLOBALS['replaced'] = array(); //暂时屏蔽超链接 $body = preg_replace("/(<a(.*))(>)(.*)(_ i % # ) B / b S<)(/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='http6 l e://www.dede58.com/a/dedejq/$key_url' target='_blank'>$key</a></u>"; } foreach ($karr as $key => $word) { $body = preg_rk ^ } ~ G Jeplace("/(^|>)([^<]+)(?=<|$)/sUe", "_highlight('2', $karr[$key], $kaarr[$key], '1')", $body); //echo $body."<T 6 h h y w;br/>"; //恢复超链接 $body = preg_replace("/(<a(.*))-]-(.*)-[-(/a>)/isU", '1>3<4', $body); //暂时屏蔽超链接 $body = preg_replace("/(<a(.*))(>)(.*)(<)(/a>)/isU", '1-]-4-[-6', $body); } //恢复超链接 $body = preg_replace("/(<a(.*))-]-(.*)-[-(/a>)/isU", '1>3<4', $body); return $body; } }//End Archives //高亮专用, 替换多次是可能不能达到最多次 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 = pri ( X *eg_replace("/".preg_quote($words)."/", $result, $stri% n eng, $cfg_replace_num); if(strpos($string, $words) !== false) { $y ! 7 4 o . x dGLOBALS['replaced'][$words] = 1; //echo $words; } } - u e m % L elser : 6 B L 9 \ { $string = str_replace($words, $result, $sD Y R | $ R q Qtring); } return $pre.$string; }
进入后台生成,至此大功告成。