实现教程
1、后台-系统-核心设置-关键字替换,选择【是】
(此图片来源于网络,如有侵权,请联系删除! )
2、后台-系统-其他选项-关键词替换次数,填【1】或者【0】
1:表示文档内容里有多个关键词,只让1个是内链
0:表示文档内容里有多个关键词,都是内| C * 6 y链
根据自己U 8 9 a A h \的需要填
(此] W g \ u ^ h y图片来源于网络,如有侵权,请联系删除! )
3、打开 /include/arc.archives.class.php 找到,大概在1187行至1241行,整个函数
function Re5 g | 6placeKeyword) \ ! \ . F (($kw,&$body) { ...中间代码省略 }
整个改成
funct2 m # s + S lion ReplaceKeyword($kw,1 \ l r z S&a G y$body) { gl9 M ,obal $cfg_replace_num; //如果当前文档没有tag直接不内链,需要匹配所有tag的话,删除下面行 if(GetTags($this->FieldL 7 ; b O a n us['aid']) == '') return $body; $J 1 y 9 , %search = "/(alts*=s*|titles*=s*|srcs*=s*)["|'](.+?)["|']/is"; $b| u W 7 B ;ody = preg_replace! & M `_callback($search, arrX 6 i U Z !ay('Archives', '_base64_encode'), $body); $addsql = ''; $thi] u + - T @ # / Ks->dsql->SetQuery("SELECT tid FROM `58p. 3 U * $ z P \ic_taglist` WHERE aid = '{$this->Fields['aid']}' "); $X E : = d ] 7 s +this->dsql->Execute(); $ids = ''; while($row = $this->dsql->GetA6 v - Trray()) { $im : vds .= ( $idsM l 2 c +=='' ? $row['tid'] : ','.$row['tid'] ); } if($id@ % ~ K D Ds != '') { $addsql = " WHERE id IN($ids) "; } $query = "SELECT| a 1 z y ~ w r - * FROM `58pic_tag. d v D 2 ) t 5index` $addsql ORDER BY addtim6 U _ 2 w { p ~e DESC"; $this->dsql->SetQuery($query)6 P f; $this->dsql->Execute(); $linkO + k C _ _datas = array(); while($row = $this->dsql->GetArray()) { $row['keyword'] = $row['tag']; $row['rpurl'] = $cfg_cmsurl."/tags.php?/".urlencode($row['tag'])."/"; $linkdatas[] = $row; } if($linkdatas) { $wordT 4 ( C E * n c = $replacement = array(); foreach($linkdatas as $v) { $word0[] = "/&lU O } a q Wt;a[^>]*>{$v['keyword']}</a>S w } ! m x H 9 v;/is"; $word1[] = '/'.$v['keyword'].'/is'; $word2[] = $v['keyword']; $replacef V n |ment[] = '&l5 _ K C nt;a href="'.$v['rpurl'].'" targb Y i ` c het="_blaM \ 6 } Ink">'.$v['keyword'].'</a>'; } if($cfg_replace_num) { $body = preg_replace($n ) E $ ? 5 i Sword0, $word2, $body, $cfg_replace_num); $body = preg_replace($word1,9 2 0 $replacement, $body, $cfg_replace_num); } else { $body = str_U % & ] $ $ )replace($word2, $replacement, $body); } } $body = preg_replace_callback($search, array('Archiver t O / Vs', '_base64_decode'), $body);z m = q n u H 1 return $body; } function _base64_encode($matches) { return $ma% / U ( o \tches[1].""".base64_encode($matches[2])."""; } funct\ v E M ^ w J cion _base64_decode($matcd = P + | M - ) Uhes) { retug w ^ 3 ; r Qrn $matches[1].""".base64_decode($matches[2])."""; }
如图
(此图片s { S V 5来源于网络,如有侵权,请联系删除! )
如果你的tag链接是伪静态或者静态链接0 _ P 9 q,把里面的
$cfg_cmsurl."/tags.php?/".urlencode($row['tag'])."/";
改成与include/taglib/tag.lib.php里面的一致即可
(此图片来源于网络,如有侵权,请联系删除! )
4、完成,动态的直接看效果,静态的记得重新生成文档看效果