您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程

ecshop自动内链优化的实现方法

沛菡2023-10-21 18:37:06ecshop商城教程已有人查阅

导读ecshop自动内链插件seo优化插件安装教程:1.打开admin\includes里面的inc_menu.php文件:2.languages\zh_cn\admin\common.php 增加语言项

ecshop自动内链插件seo优化安装教程:
1.打开admin\includes里面的inc_menu.php文件:
添加:
$modules['11_system']['auto_neilian'] = 'auto_neilian.php?act=list_edit'; // ecshop自动内链插件
2.languages\zh_cn\admin\common.php 增加语言项
/* 系统设置 */
$_LANG['01_shop_config'] = '商店设置';
$_LANG['auto_neilian'] = '自动添加内链设置';
3  修改跟目录article.php  
搜索:  
./* 获得文章的信息 *
找到:
$row['author'] = $GLOBALS['_CFG']['shop_name'];
在:
{
$row['author'] = $GLOBALS['_CFG']['shop_name'];
}
下方增加:
//seo内链插件 start
function str_replace_once($needle, $replace, $haystack) {
//函数作用,只替换一次字符
//$needle --- 需要替换的字符
//$replace --- 替换成什么字符
//$haystack --- 需要操作的字符串
   $pos = strpos($haystack, $needle);
   if ($pos === false) {
  return $haystack;
   }
   return substr_replace($haystack, $replace, $pos, strlen($needle));
}
$content = file_get_contents("data/auto_neilian.php");
$array   = explode("\r\n",$content);
foreach ($array AS $value){
   $tmp =  explode("---",$value);
   if ($tmp !== false){
if($tmp[1]){
    $str = "<a target='_blank' href='".$tmp[1]."'>".$tmp[0]."</a>";
}
else{
    $str = "<a target='_blank' href='search.php?keywords=".rawurlencode($tmp[0])."'>".$tmp[0]."</a>";
}
$str_1 = $tmp[0];
$str_2 = $str;
$tmp1 = explode("<",$row['content']);
foreach ($tmp1 as $key=>$item){
 $tmp2 = explode(">",$item);
 if (sizeof($tmp2)>1) {
  if(substr($tmp2[0],0,1)!="a" && substr($tmp2[0],0,1)!="A"){
     if(strpos($tmp2[1],$str_1)!==false){
$tmp2[1] = str_replace_once($str_1,$str_2,$tmp2[1]);
$tmp1[$key] = implode(">",$tmp2);
break;
     }
  }
 }
}
$row['content'] = implode("<",$tmp1);
   }
  }
//seo内链插件 end
4.  修改跟目录goods.php 
/* 如果没有找到任何记录则跳回到首页 */
ecs_header("Location: ./\n");
exit;
}
else
{
下方增加:
//seo内链插件 start
//$content = iconv("GB2312","UTF-8",file_get_contents("data/auto_neilian.php"));
function str_replace_once($needle, $replace, $haystack) {
//函数作用,只替换一次字符
//$needle --- 需要替换的字符
//$replace --- 替换成什么字符
//$haystack --- 需要操作的字符串
$pos = strpos($haystack, $needle);
   if ($pos === false) {
  return $haystack;
   }
   return substr_replace($haystack, $replace, $pos, strlen($needle));
}
$content = file_get_contents("data/auto_neilian.php");
$array   = explode("\r\n",$content);
foreach ($array AS $value){
   $tmp =  explode("---",$value);
   if ($tmp !== false){
if($tmp[1]){
    $str = "<a target='_blank' href='".$tmp[1]."'>".$tmp[0]."</a>";
}
else{
    $str = "<a target='_blank' href='search.php?keywords=".rawurlencode($tmp[0])."'>".$tmp[0]."</a>";
}
$str_1 = $tmp[0];
$str_2 = $str;
$tmp1 = explode("<",$goods['goods_desc']);
foreach ($tmp1 as $key=>$item){
 $tmp2 = explode(">",$item);
 if (sizeof($tmp2)>1) {
  if(substr($tmp2[0],0,1)!="a" && substr($tmp2[0],0,1)!="A"){
     if(strpos($tmp2[1],$str_1)!==false){
$tmp2[1] = str_replace_once($str_1,$str_2,$tmp2[1]);
$tmp1[$key] = implode(">",$tmp2);
break;
     }
  }
 }
}
$goods['goods_desc'] = implode("<",$tmp1);
   }
  }
//seo内链插件 end
5. 剩下全部覆盖就可以了 !

本文标签:

很赞哦! ()

相关文章

留言与评论 (共有 条评论)
验证码:

本栏推荐

相关标签