商品描述增加多个商品描述编辑器的方法
更新时间:2016-06-27 点击量:1635
Tag关键词: 编辑器 ecshop模板 ecshop4.0模板 二次开发 ecshop3.6模板 ecshop小程序
因后台默认只有一个编辑器,在这里优易软件为大家整理关于在商品描述增加多个商品描述编辑器的方法
首先,需要写入数据库字段。写入的方法可以在后台SQL查询,执行以下语句alter table ecs_goods add goods_shipai text not null;
这里演示写入的字段为goods_shipai 。
修改内容存储进数据库的文件,打开 /admin/goods.php 搜索:goods_desc
大概150行:
/* 取得商品信息 */ if ($is_add) { /* 默认值 */ $last_choose = array(0, 0); if (!empty($_COOKIE['ECSCP']['last_choose'])) { $last_choose = explode('|', $_COOKIE['ECSCP']['last_choose']); } $goods = array( 'goods_id' => 0, 'goods_desc' => '', 下面增加: /* 取得商品信息 */ if ($is_add) { /* 默认值 */ $last_choose = array(0, 0); if (!empty($_COOKIE['ECSCP']['last_choose'])) { $last_choose = explode('|', $_COOKIE['ECSCP']['last_choose']); } $goods = array( 'goods_id' => 0, 'goods_desc' => '', 'goods_shipai' => '', 'cat_id' => $last_choose[0],
第2 地方大概:231行:
/* 默认值 */ $goods = array( 'goods_id' => 0, 'goods_desc' => '', 'goods_shipai' => '', 'cat_id' => 0,
3. 搜索 create_html_editor('goods_desc', $goods['goods_desc']);增加为如下:
/* 创建 html editor */ create_html_editor('goods_desc', $goods['goods_desc']); create_html_editor2('goods_shipai', 'goods_shipai',$goods['goods_shipai']);
4.入库操作的修改,注意,这里新增了goods_shipai字段:
/* 入库 */ 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 , goods_shipai )" . "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[goods_shipai]')"; } 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 , goods_shipai)" . "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' , '$_POST[goods_shipai]')"; } } else {
5.更新字段
/* 如果有上传图片,需要更新数据库 */ if ($goods_img) { $sql .= "goods_img = '$goods_img', original_img = '$original_img', "; } if ($goods_thumb) { $sql .= "goods_thumb = '$goods_thumb', "; } if ($code != '') { $sql .= "is_real=0, extension_code='$code', "; } $sql .= "keywords = '$_POST[keywords]', " . "goods_brief = '$_POST[goods_brief]', " . "seller_note = '$_POST[seller_note]', " . "goods_weight = '$goods_weight'," . "goods_number = '$goods_number', " . "warn_number = '$warn_number', " . "integral = '$_POST[integral]', " . "give_integral = '$give_integral', " . "rank_integral = '$rank_integral', " . "is_best = '$is_best', " . "is_new = '$is_new', " . "is_hot = '$is_hot', " . "is_on_sale = '$is_on_sale', " . "is_alone_sale = '$is_alone_sale', " . "is_shipping = '$is_shipping', " . "goods_desc = '$_POST[goods_desc]', " . "goods_shipai = '$_POST[goods_shipai]', " . "last_update = '". gmtime() ."', ". "goods_type = '$goods_type' " . "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1"; } $db->query($sql);
6.找到admin/ includes/lib_main.php 约306行:
/** * 生成编辑器 * @param string input_name 输入框名称 * @param string input_value 输入框值 */ function create_html_editor($input_name, $input_value = '') { global $smarty; $editor = new FCKeditor($input_name); $editor->BasePath = '../includes/fckeditor/'; $editor->ToolbarSet = 'Normal'; $editor->Width = '100%'; $editor->Height = '320'; $editor->Value = $input_value; $FCKeditor = $editor->CreateHtml(); $smarty->assign('FCKeditor', $FCKeditor); } //第2个商品编辑器 /** * 生成编辑器2 * @param string input_name 输入框名称 * @param string input_value 输入框值 */ function create_html_editor2($input_name, $output_name , $input_value = '') { global $smarty; $editor = new FCKeditor($input_name); $editor->BasePath = '../includes/fckeditor/'; $editor->ToolbarSet = 'Normal'; $editor->Width = '100%'; $editor->Height = '320'; $editor->Value = $input_value; $FCKeditor = $editor->CreateHtml(); $smarty->assign($output_name, $FCKeditor);//这里输出就用$output_name变量了。 }
7.修改一下对应的后台显示文件 /admin/templates/goods_info.htm
<table width="90%" id="detail-table" style="display:none"> <tr> <td>产品实拍:</td> </tr> <tr> <td>{$goods_shipai}</td> </tr> </table>
8.最后修改模板文件。修改商品页模板goods.dwt: 在需要的位置增加
{$goods.goods_shipai}
9. 后台刷新并点击清除后台缓存,重新添加商品,应该就可以看到修改后的成果了。
如果文章对您有帮助,就打赏一个吧
«上一篇:ecshop商城网站顶部会员如何实现ajax免刷新登录登出 下一篇:ECSHOP在不同商品分类状态下如何调用不同模板»