First, explain the meaning of the "frequency" in keyword maintenance in the document. We know that Zhimeng is set to 30 by default, and many friends regard it as the number of links to the anchor text. In fact, this frequency only indicates the keyword popularity, which is equivalent to the keyword weight of the mobile system. It's just that the dream cannot be handled well in this place. Therefore, I suggest you do not change it.
So how should we control the number of document anchor text links? The last line of other options in system basic parameters. The number of times the same keyword is replaced in the document content (0 is replaced with all): 1 (1 indicates that only the first target keyword is linked ). As shown in the following figure:
Here, another problem may occur. For example, I set up two anchor texts in the background to link "SEO Blog" and "SEO", but when the word "SEO blog" appears for the first time, originally, the idea was to link to the page corresponding to "SEO Blog", but Zhimeng is set to link to the page corresponding to "SEO" by default. So how should we deal with this situation?
Solution (back up data first)
Step 1: Open arc. archivew. class. php in the include Directory
Find the function ReplaceKeyword ($ kw, & $ body) code, from here to the bottom. Replace this code:
The code is as follows: |
Copy code |
Function ReplaceKeyword ($ kw, & $ body)
{
Global $ cmd_cmspath;
$ Maxkey = 5;
$ Kws = explode (",", trim ($ kw); // take good scores as the delimiter
$ I = 0;
$ Karr = $ kaarr = $ GLOBALS ['replace Ed'] = array ();
// Temporarily shield the hyperlink
$ Body = preg_replace ("/(<(. *) (> )(. *) (<) (/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 = '$ key_url' target = '_ blank'> $ key </a> </u> ";
}
Foreach ($ karr as $ key => $ word)
{
$ Body = preg_replace ("/(^ |>) ([^ <] + )(? = <| $)/SUe "," _ highlight ('\ 2', $ karr [$ key], $ kaarr [$ key],' \ 1 ')", $ body );
// Echo $ body. "<br/> ";
// Restore a hyperlink
$ Body = preg_replace ("/(<(. *)-]-(. *)-[-(/a>)/isU ", '\ 1> \ 3 <\ 4', $ body );
// Temporarily shield the hyperlink
$ Body = preg_replace ("/(<(. *) (> )(. *) (<) (/a>)/isU ", '\ 1-]-\ 4-[-\ 6', $ body );
}
// Restore a hyperlink
$ Body = preg_replace ("/(<(. *)-]-(. *)-[-(/a>)/isU ", '\ 1> \ 3 <\ 4', $ body );
Return $ body;
}
} // End Archives
// Special for highlight. The maximum number of replacement times may not be reached
Function _ highlight ($ string, $ words, $ result, $ pre)
{
Global $ replace_num;
$ String = str_replace ('"', '"', $ string );
If ($ GLOBALS ['replace Ed'] [$ words] = 1)
{
Return $ pre. $ string;
}
If ($ replace_num> 0)
{
$ String = preg_replace ("/". preg_quote ($ words). "/", $ result, $ string, $ pai_replace_num );
If (strpos ($ string, $ words )! = False)
{
$ GLOBALS ['replace Ed'] [$ words] = 1;
// Echo $ words;
}
}
Else
{
$ String = str_replace ($ words, $ result, $ string );
}
Return $ pre. $ string;
}
|
Go to the background to generate the file. This is a success.