ecshop站点地图sitemap.xml生成后其实是有错误的,而且错的很严重,特别是新手想优化网站,按照网上教程做了站点地图,最后乱套了。在百度等搜索引擎支持情况下,错的严重,当然收录不好了。 ecshop模板堂这里说明三点修改,都是以后台admin/sitemap.php文件为例 1.把ecshop站点地图sitemap.xml生成改成绝对路径。 找到43到48行 $domain = $ecs->url(); $today = local_date('Y-m-d'); $sm =& new google_sitemap(); $smi =& new google_sitemap_item($domain, $today, $_POST['homepage_changefreq'], $_POST['homepage_priority']); $sm->add_item($smi); 修改成 $domain = ''; $today = local_date('Y-m-d'); $sm =& new google_sitemap(); $smi =& new google_sitemap_item('http://www./', $today, $_POST['homepage_changefreq'], $_POST['homepage_priority']); $sm->add_item($smi); 好处是,做了自定义URL,改了绝对路径后,地图生成网址也是对的 2. 把ecshop站点地图sitemap.xml生成的文章附件URL网址去除 找到95到105行 /* 文章 */ $sql = "SELECT article_id,title,file_url,open_type FROM " .$ecs->table('article'). " WHERE is_open=1"; $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $article_url=$row['open_type'] != 1 ? build_uri('article', array('aid'=>$row['article_id']), $row['title']) : trim($row['file_url']); $smi =& new google_sitemap_item($domain . $article_url, $today, $_POST['content_changefreq'], $_POST['content_priority']); $sm->add_item($smi); } 修改成 /* 文章 */ $sql = "SELECT article_id,title,file_url,open_type FROM " .$ecs->table('article'). " WHERE is_open=1"; $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $smi =& new google_sitemap_item($domain . build_uri('article', array('aid' => $row['article_id']), $row['title']), $today, $_POST['content_changefreq'], $_POST['content_priority']); $sm->add_item($smi); } 这样去除了附件或者跳转网址,整个地图都是自己网站的了 3. 把品牌网址加入到ecshop地图当中 这在代码 clear_cache_files(); // 清除缓存 前加入好了 /* 品牌 */ $sql = "SELECT brand_id,brand_name FROM " .$ecs->table('brand'). " WHERE is_show=1"; $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $smi =& new google_sitemap_item($domain . build_uri('brand', array('bid' => $row['brand_id']), $row['brand_name']), $today, $_POST['category_changefreq'], $_POST['category_priority']); $sm->add_item($smi); } 这样商品品牌也会出现在地图当中。地图当然需要权重了。 总体以上ecshop模板堂的方法,地图就比较丰富实用了很多,商品,分类,文章,品牌全部都存在。 PS: 以上红色标注的是修改与增加的ecshop代码! 下一篇: 解决ecshop报错BIGINT UNSIGNED value is out of range in 上一篇: 解决ecshop添加分类后台不显示前台显示 |
|