当PHP版本高于5.5时,织梦DedeCMS无法使用关键词內链,下面是此问题的解决方法。
打开 /include/arc.archives.class.php 找到
1 | $body = @preg_replace_callback( "#(^|>)([^<]+)(?=<|$)#sU" , "_highlight('\\2', \$karr, \$kaarr, '\\1')" , $body); |
|
改成:
01 | global $cfg_replace_num; |
02 | if ($cfg_replace_num > 0) |
04 | $query = "SELECT char_length(keyword) AS num,aid,keyword,rpurl,rank FROM xiuzhanwang_keywords WHERE rpurl<>'' ORDER BY num DESC" ; |
05 | $this->dsql->SetQuery($query); |
06 | $this->dsql->Execute(); |
07 | while ($row = $this->dsql->GetArray()) |
09 | $key = trim($row[ 'keyword' ]); |
10 | $key_url=trim($row[ 'rpurl' ]); |
11 | $body = str_replace_limit($key, "<a href='$key_url' target='_blank'><u>$key</u></a>" , $body, $cfg_replace_num); |
16 | $query = "SELECT char_length(keyword) AS num,aid,keyword,rpurl,rank FROM xiuzhanwang_keywords WHERE rpurl<>'' ORDER BY num DESC" ; |
17 | $this->dsql->SetQuery($query); |
18 | $this->dsql->Execute(); |
19 | while ($row = $this->dsql->GetArray()) |
21 | $key = trim($row[ 'keyword' ]); |
22 | $key_url=trim($row[ 'rpurl' ]); |
23 | $body = str_replace($key, "<a href='$key_url' target='_blank'><u>$key</u></a>" , $body); |
|
继续找到:
在它上面加入:
02 | function str_replace_limit($search, $replace, $subject, $limit) |
06 | foreach($search as $k=>$ v ) |
08 | $search[$k] = '#(?<!>)(?!<)' . preg_quote($search[$k], '#' ). '#' ; |
13 | $search = '#(?<!>)(?!<)' . preg_quote($search, '#' ). '#' ; |
15 | return preg_replace($search, $replace, $subject, $limit); |
|
发表评论
评论列表(0条)