dedecsm 5.5全内链修改 |
时间:2009-08-26 00:00:00 来源:TIANZI.ORG 作者:天子 阅读:1845次 |
|
|
dedecms 5.5全内链修改方法,所有设置关键词的内链都会在文档中创建,突破keyword的限制 找到include/arc.archives.class 文件 在文件中的 ReplaceKeyword 函数 下面 找到 $body = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', $body); 再在后面增加:
//设置所有关键词 $dsql12 = new DedeSql(); $query1="select * from #@__keywords"; $dsql12->SetQuery($query1); $dsql12->Execute(); while($kws = $dsql12->GetArray()) {
//------------------------------------------------------------- 然后删除 if($i > $maxkey) { break; } 最后一步当然是要补上一个"}"
修改后完整的代码是:
function ReplaceKeyword($kw,&$body) { global $cfg_cmspath; $maxkey = 5; $kws = explode(",",trim($kw)); //以分好为间隔符 $i=0; $karr = $kaarr = $GLOBALS['replaced'] = array();
//暂时屏蔽超链接 $body = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', $body);
//设置所有关键词 $dsql12 = new DedeSql(); $query1="select * from #@__keywords"; $dsql12->SetQuery($query1); $dsql12->Execute(); while($kws = $dsql12->GetArray()) {
foreach($kws as $k) { $k = trim($k); if($k!="") { $myrow = $this->dsql->GetOne("select * from #@__keywords where keyword='$k' And rpurl<>'' "); if(is_array($myrow)) { $karr[] = $k; $GLOBALS['replaced'][$k] = 0; $kaarr[] = "<a href='{$myrow['rpurl']}'><u>$k</u></a>"; } $i++; } } } $body = preg_replace("/(^|>)([^<]+)(?=<|$)/sUe", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body);
//恢复超链接 $body = preg_replace("/(<a(.*))-\]-(.*)-\[-(\/a>)/isU", '\\1>\\3<\\4', $body); return $body; } |
|
|
|
|
|