<th id="1dxm2"><option id="1dxm2"></option></th><object id="1dxm2"></object>

<th id="1dxm2"><video id="1dxm2"></video></th>
    <th id="1dxm2"><option id="1dxm2"></option></th>

    <nav id="1dxm2"></nav>

  1. <object id="1dxm2"></object>
        1. 0712-2888027 189-8648-0214
          微信公眾號

          孝感風信網絡科技有限公司微信公眾號

          當前位置:主頁 > 技術支持 > PHPCMS > phpcms v9關鍵字,內聯,關聯鏈接完美解決方案

          phpcms v9關鍵字,內聯,關聯鏈接完美解決方案

          時間:2023-03-21來源:風信官網 點擊: 234次

          由于PHPCMS關鍵字關聯鏈接替換的時候 對ALT標簽也會替換掉  還有A標簽內的東西也會替換掉 這樣不是我們的本意,搜遍論壇沒有解決方案,看到一個網站解決了,問了下那個朋友,人家告訴我1000元,說官方都沒有解決的問題 你說值不值1000,我就納悶了,自己研究了下DEDE和帝國的程序,搞明白了怎么回事,現在將研究的方法分享出來:

          找到include目錄下的global.func.php文件,用編輯軟件打開后,CTRL+F搜索function keylinks

          然后將:

          function keylinks($txt, $replacenum = '')
          {
          $linkdatas = cache_read('keylink.php','',1);
          if($linkdatas)
          {
          $word = $replacement = array();
          foreach($linkdatas as $v)
          {
          $word1[] = '/'.preg_quote($v[0], '/').'/';
          $word2[] = $v[0];
          $replacement[] = '<a href="'.$v[1].'" target="_blank" class="keylink">'.$v[0].'</a>';
          }
          if($replacenum != '')
          {
          $txt = preg_replace($word1, $replacement, $txt, $replacenum);
          }
          else
          {
          $txt = str_replace($word2, $replacement, $txt);
          }
          }
          return $txt;
          }

          替換成以下代碼:

          function keylinks($txt, $replacenum = '')
          {
          $linkdatas =
          cache_read('keylink.php','',1);

          //暫時屏蔽超鏈接
          $txt
          = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6',
          $txt);

          $GLOBALS['replaced'] = array();

          if($linkdatas)
          {
          $word = $replacement =
          array();
          foreach($linkdatas as
          $v)
          {
          $word[] =
          $v[0];
          $GLOBALS['replaced'][$v[0]] =
          0;
          $replacement[] = '<a href="'.$v[1].'" target="_blank"
          class="keylink">'.$v[0].'</a>';
          }
          }
          $txt
          = preg_replace("/(^|>)([^<]+)(?=<|$)/sUe", "_highlight('\\2', \$word,
          \$replacement, '\\1',\$replacenum)", $txt);

          //恢復超鏈接
          $txt = preg_replace("/(<a(.*))-\]-(.*)-\[-(\/a>)/isU", '\\1>\\3<\\4', $txt);

          //高亮專用, 替換多次是可能不能達到最多次
          function _highlight($string, $words, $result,
          $pre ,$cfg_replace_num)
          {
          $string = str_replace('\"', '"',
          $string);
          if($cfg_replace_num > 0)
          {
          foreach
          ($words as $key =>
          $word)
          {
          if($GLOBALS['replaced'][$word] ==
          1)
          {
          continue;
          }
          $string
          = preg_replace("/".preg_quote($word)."/", $result[$key], $string,
          $cfg_replace_num);
          if(strpos($string, $word) !==
          false)
          {
          $GLOBALS['replaced'][$word]
          =
          1;
          }
          }
          }
          else
          {
          $string
          = str_replace($words, $result, $string);
          }
          return
          $pre.$string;
          }

          就ok了

          現在實現的功能是:
          第一就是會替換所有的關聯關鍵字
          第二如果替換次數在模型設置里面設置的是大于0的話,每個關鍵字只替換一次,主要考慮到替換太多 不利于SEO
          在生成速度上會慢些,還有就是在后臺加的關鍵字會全部替換,要是關鍵字太密集的話,也會不利于搜索引擎優化。 實現起來也不難。

          要想一個關鍵字可以使用下面的代碼:

          //高亮專用, 替換多次是可能不能達到最多次
          function _highlight($string, $words, $result, $pre ,$cfg_replace_num)
          {

          $string = str_replace('\"', '"', $string);
          if($cfg_replace_num > 0)
          {
          foreach ($words as $key => $word)
          {
          if($GLOBALS['replaced'][$word] == $cfg_replace_num)
          {
          continue;
          }
          $string = preg_replace("/".preg_quote($word)."/", $result[$key], $string, $cfg_replace_num);
          if(strpos($string, $word) !== false)
          {
          $GLOBALS['replaced'][$word] ++;
          }
          }
          }
          else
          {
          $string = str_replace($words, $result, $string);
          }
          return $pre.$string;
          }

          熱門關鍵詞: phpcms 關鍵字 內聯 關聯鏈接
          欄目列表
          推薦內容
          熱點內容
          展開
          特级欧美a片免费观看

          <th id="1dxm2"><option id="1dxm2"></option></th><object id="1dxm2"></object>

          <th id="1dxm2"><video id="1dxm2"></video></th>
            <th id="1dxm2"><option id="1dxm2"></option></th>

            <nav id="1dxm2"></nav>

          1. <object id="1dxm2"></object>