ecshop商品自定义url和标题
2011-11-06 23:55 来源:www.chinab4c.com 作者:ecshop专家
ecshop商品自定义url和标题,这个是很多人都追求的一个功能。现在的ecshop的模板和路径千篇一律。为了让ecshop更加符合ecshop SEO优化。我们就不得不对ecshop url和标题进行自定义。我们可以通过对ecshop二次开发。来让ecshop商品地址实现自定义url
1:修改数据库。增加字段
alter table ecs_goods add column url varchar(40) default '';
2:goods_info.htm
<tr>
<td class="label">自定义URL</td>
<td><input type="text" name="url" value="{$goods.url}" size="30" /></td>
</tr>
3:admin/goods.php修改以下程序
$url = !empty($_POST['url']) ? trim($_POST['url']) : '';
/* 入库 */
if ($is_insert)
{
if ($code == '')
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id,url)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id','$url')";
}
else
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral,url)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral','$url')";
}
}
4:伪静态规则。必须修改成以下
RewriteRule ^([0-9a-zA-Z]+)-([0-9]+)(.*)\.html$ goods\.php\?id=$2 [QSA,L]
5:build_uri函数商品重写修改成以下
case 'goods':
if (empty($gid))
{
return false;
}
else
{
$url = $GLOBALS['db']->getOne("select url from ".$GLOBALS['ecs']->table('goods')." where goods_id = '$gid'");
if($url){
$uri = $rewrite ? $url."-".$gid : 'goods.php?id=' . $gid;
}else{
$uri = $rewrite ? 'goods-' . $gid : 'goods.php?id=' . $gid;
}
}
break;
最近更新
常用插件
- ecshop购物车勾选功能
ecshop购物车勾选功能...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop会员中心订单列表信
ecshop插件介绍: 1.前台我的订单:增加显示 收件人栏 和 发货快递单号栏...
- ecshop整合baidu百度开放平台
大家都知道,baidu的开放平台已经很成熟了。可以方便中小型B2C企业数据...
- ecshop二次开发软件订购流
ecshop二次开发软件订购流程插件,使用该插件,其实就意味着给ecshop的软件...