ecshop商品上一个下一个改为产品名称

2016-06-13 13:05 来源:www.chinab4c.com 作者:ecshop专家

ecshop商品详情里默认有“上一个”和“下一个”的链接,链接的是在商品分类里前一个ID和后一个ID的商品。通常这并没有什么问题,但如果对于一个一个吹毛求疵的优化人员,这个锚文本并不良好。我们都知道,链接的形式最好是以锚文本的形式,即链接页关键词写在链接文本里,这样能优化该关键词的排名。 而对于ecshop产品的关键字多数是它的产品名称,我们需要将此时的“上一个”和“下一个”的链接改为产品名称。操作修改如下: 找到根目录下的goods.php,将以下代码 /* 上一个商品下一个商品 */ $prev_gid = $db->getOne(“SELECT goods_id FROM ” .$ecs->table(‘goods’). ” WHERE cat_id=” . $goods['cat_id'] . ” AND goods_id > ” . $goods['goods_id'] . ” AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1″); if (!empty($prev_gid)) { $prev_good['url'] = build_uri(‘goods’, array(‘gid’ => $prev_gid), $goods['goods_name']); $smarty->assign(‘prev_good’, $prev_good);//上一个商品 } $next_gid = $db->getOne(“SELECT max(goods_id) FROM ” . $ecs->table(‘goods’) . ” WHERE cat_id=”.$goods['cat_id'].” AND goods_id < “.$goods['goods_id'] . ” AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0″); if (!empty($next_gid)) { $next_good['url'] = build_uri(‘goods’, array(‘gid’ => $next_gid), $goods['goods_name']); $smarty->assign(‘next_good’, $next_good);//下一个商品 } 修改成以下代码(红色部分是修改内容) /* 上一个商品下一个商品 */ $prev_gid = $db->getRow(“SELECT goods_id,goods_name FROM ” .$ecs->table(‘goods’). ” WHERE cat_id=” . $goods['cat_id'] . ” AND goods_id > ” . $goods['goods_id'] . ” AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1″); if (!empty($prev_gid)) { $prev_good['url'] = build_uri(‘goods’, array(‘gid’ => $prev_gid['goods_id']), $goods['goods_name']); $prev_good['goods_name'] =$prev_gid['goods_name']; $smarty->assign(‘prev_good’, $prev_good);//上一个商品 } $next_gid = $db->getRow(“SELECT goods_id,goods_name FROM ” . $ecs->table(‘goods’) . ” WHERE cat_id=”.$goods['cat_id'].” AND goods_id < “.$goods['goods_id'] . ” AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 order by goods_id desc limit 1″); if (!empty($next_gid)) { $next_good['url'] = build_uri(‘goods’, array(‘gid’ => $next_gid['goods_id']), $goods['goods_name']);             $next_good['goods_name'] =$next_gid['goods_name']; $smarty->assign(‘next_good’, $next_good);//下一个商品 } 再找到模板文件(默认模板)里的goods.dwt,将以下代码(上一个) ”prev” 修改成 {$prev_good.goods_name} 以下代码(下一个) ”next” 修改成 {$next_good.goods_name}   至此,将这个细节优化好,我们便相当于为每个产品增加了一个内链的锚文本,对于seo来说是体验度非常高了。