结合ecshop后台商品编辑和商品录入。来谈谈如何给ecshop商品增加新的字段。当然这个字段是为了满足对ecshop二次开发的需要而设置的。
1:我们必须给ecshop商品表增加字段:other_col
alter table ecs_goods add column other_col varchar(64);
2:在ecshop后台的admin\templates\goods_info.htm中增加以下代码.
<tr> <td class="label">自定义字段</td> <td><input type="text" name="other_col" value="{$goods.other_col}" size="20"/> </td> </tr>
3:在admin/goods.php的elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update')里面增加以下程序
$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,other_col)" . "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','$_POST[other_col]')";
这样我们就完成了后台录入新字段的程序修改了。
那么在ecshop数据库表的goods中。我们就取得他的值.在前台通过{$goods.other_col}来完成新增字段的显示。
|