Empire CMS keyword and image link conflict resolution code collection?
Blood wolf SEO 2021-02-23 07:42:59

Problem description : In the Empire CMS Enable the content keyword function in the background ( Let the published articles automatically add the inner chain ), Pictured .

 The empire CMS Keywords conflict with image links Solve code collection ?


chart : The empire CMS Enable the content keyword function in the background

But because of too many keywords in the chain , In addition, some key words are mixed Chinese and English , Such as SEO The word optimization , Or because the keywords are similar, let the Empire CMS There's chaos in the system ( For example, a keyword link entry is called HTML, Another key link entry is called HTML5), So when you publish content , The first picture doesn't work ( But the first image is normal as a thumbnail , The picture itself has been uploaded to the website space ).

 The empire CMS Keywords conflict with image links Solve code collection ?

The picture doesn't show


Go to the source code , Will see that <img> The labels are in a mess .

<img> The tag code has been ruined like this :

<p><img src=”/d/file/<a href=http://www.qidiantong.com/photoshop/ target=_blank class=infotextkey>photoshop</a>/20160711/d332b3635c7b74ea7448eeddc68dc9ea.jpg” alt=”PS Poster tutorial PS course PS Text course ” border=”0” /></p>

I found this problem some time ago , Tried to do some patching , One is in the Empire CMS Background deleted some similar keyword link entries , And then regenerate the website HTML page .

In addition to deleting some similar keyword link entries to avoid errors , Second, for pages that have made mistakes , It's manual modification , Cancel on modification : Keyword substitution a .

 The empire CMS Keywords conflict with image links Solve code collection ?

Keyword replacement function


The above method adopted by Huage , It's a stupid way , Not smart enough . Only the programmers on the Internet come out , To provide a solution once and for all .

Recently I saw a better solution , Put it on the website , Although not strictly tested for accuracy , But at least it won't make any mistakes , Because at the time of publishing these days , No longer see the first picture in the content of the article does not show the problem of crossing . as follows :

 The empire CMS Keywords conflict with image links Solve code collection ?

The empire cms Keywords conflict with links


Solve the conflict between imperial keywords and image links

Three steps :

1、 Take out pictures and links .

2、 Replace content keywords .

3、 Put back pictures and links .

stay e/class/functions.php in , Look for code :“ function ReplaceKey($newstext,$classid=0)” or “// Replace keyword ”( Sometimes open for utf-8 Chinese is garbled )

Take a large part of this ( namely :“// Replace keyword ” part ) Replace with the following code :

———————————————————————————————–

// Replace keyword

function ReplaceKey($newstext,$classid=0){

global $empire,$dbtbpre,$public_r,$class_r;

if(empty($newstext)||$class_r[$classid][‘keycid’]==-1)

{return $newstext;}

$where=”;

if(!empty($class_r[$classid][‘keycid’]))

{

$where=” where cid='”.$class_r[$classid][‘keycid’].”‘”;

}

$newstext=stripslashes($newstext);

preg_match_all(‘/<a[^>](.*)a>|<img[^>](.*)>/isU’,stripslashes($newstext),$rs);

if($rs[0]){

foreach($rs[0] as $k=>$v){

$newstext=str_replace($v,”[!–{$k}–]”,$newstext);

}

}

$sql=$empire->query(“select keyname,keyurl from {$dbtbpre}enewskey”.$where);

while($r=$empire->fetch($sql))

{

if(STR_IREPLACE)

{

$newstext=empty($public_r[repkeynum])?str_ireplace($r[keyname],'<a href=’.$r[keyurl].’ target=_blank class=infotextkey>’.$r[keyname].'</a>’,$newstext):preg_replace(‘/’.$r[keyname].’/i’,'<a href=’.$r[keyurl].’ target=_blank class=infotextkey>’.$r[keyname].'</a>’,$newstext,$public_r[repkeynum]);

}

else

{

$newstext=empty($public_r[repkeynum])?str_replace($r[keyname],'<a href=’.$r[keyurl].’ target=_blank class=infotextkey>’.$r[keyname].'</a>’,$newstext):preg_replace(‘/’.$r[keyname].’/i’,'<a href=’.$r[keyurl].’ target=_blank class=infotextkey>’.$r[keyname].'</a>’,$newstext,$public_r[repkeynum]);

}

}

if($rs[0]){

foreach($rs[0] as $k=>$v){

$newstext=str_replace(“[!–{$k}–]”,$v,$newstext);

}

}

return $newstext;

}

版权声明
本文为[Blood wolf SEO]所创,转载请带上原文链接,感谢
https://fheadline.com/2021/02/20210223074215060M.html
相似文章

2021-08-09