ECSHOP各版本的商品信息表中都只提供了一个 text 类型的字段,通常不能满足应用需要,所以自己动手。
完成后效果如下:前台商品展示页:后台商品添加修改页:下面讲解修改方法:
首先在数据库中的商品信息表添加相应字段。
添加字段的SQL语句为:
ALTER TABLE `ecs(前缀)_goods` ADD `goods_desc1` TEXT NOT NULL AFTER `goods_desc`;
然后修改后台相关文件与模版。
后台中编辑器是FCKeditor,先到 admin/includes/lib_main.php 中参照 create_html_editor 函数添加一个新的函数用来生成后台编辑器。添加函数如下:
function pv_create_html_editor($input_name, $input_value = '', $i) { global $smarty; $editor = new FCKeditor($input_name); $editor->BasePath = '../includes/fckeditor/'; $editor->ToolbarSet = 'Normal'; $editor->Width = '100%'; $editor->Height = '320'; $editor->Value = $input_value; $FCKeditorx = $editor->CreateHtml(); $smarty->assign('FCKeditor'.$i, $FCKeditorx); }
然后打开 admin/goods.php ,查找 create_html_editor ,并在其后添加如下语句:
pv_create_html_editor('goods_desc1', $goods['goods_desc1'], 1);
继续在admin/goods.php中查找所有 goods_desc ,相应新增 goods_desc1
如在
'goods_desc' = '',
的后面添加
'goods_desc1' => '',
以及将
$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, goods_desc, add_time, last_update, goods_type, rank_integral)" . "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', ". " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
$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, goods_desc, goods_desc1, add_time, last_update, goods_type, rank_integral)" . "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', ". " '$_POST[goods_desc]', '$_POST[goods_desc1]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
等
接下来修改后台模板文件admin/templates/goods_info.htm
共有两处改动。一是在 {$lang.tab_detail}
后面添加
{$lang.tab_detail1}
后添加
注意标签栏与内容框ID的对应关系:
detail-tab 对应的是 detail-tabledetail1-tab 对应的是 detail1-table还可以继续添加detail2-tab 对应 detail2-table以及更多。然后在语言包文件languages/zh_cn/admin/goods.php中添加
$_LANG['tab_detail1'] = '成分(举例)';
就完成了。
之后,后台就有两个详细描述字段了。
你就可以在前台模板文件中以{$goods.goods_desc1}来引用新添加字段中的内容了。前台修改说明:找到模板下的goods.dwt找到 <!--商品描述,商品属性 START-->
这个标志然后tag标签放到<h2>和其余的class一样,下边对应的是<blockquote></blockquote>。。。ok。。这样就修改完成了。。。
附:修改好的文件包,直接上传覆盖,并在数据库中添加相应字段goods_desc1即可使用。
上述两个文件包分别对应两个版本,2.6.1版中添加了两个字段,2.7.0版中只添加了一个。
有兴趣的朋友可以下载后对照原版文件学习研究。
转载来自:。。复制粘贴代码很累的