ecshop设置一个子类对应多个父类并指定跳转url的修改方法
2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家
本文主要作用是将一个子类对应多个父类,并指定条跳转url的功能。ecshop是一款在线购物网站,感兴趣的可以下载源码看看。我们看看具体是怎么修改的。
1、数据库表“表前缀_category”添加如下字段
alter TABLE `ga_category` add `assign_child` varchar(255) default NULL;
alter TABLE `ga_category` add `jump_url` varchar(255) default NULL;
2、includes/lib_goods.php
get_categories_tree、get_child_tree函数中的
$cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
改为
if(isset($row['jump_url']) != NULL && trim($row['jump_url']) != ''){
$cat_arr[$row['cat_id']]['url'] = $row['jump_url'];
}else{
$cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
}
将
$three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
改为
if(isset($row['assign_child']) != NULL && trim($row['assign_child']) != ''){
$three_arr[$row['cat_id']]['cat_id'] = get_assign_child_tree($row['assign_child']);
}else{
$three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
}
将将获取子类的sql
$sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' .
'FROM ' . $GLOBALS['ecs']->table('category') .
"WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
改为(添加assign_child, jump_url两个字段用于查询用)
$sql = 'SELECT cat_id,cat_name ,parent_id,is_show, template_file, assign_child, jump_url ' .
'FROM ' . $GLOBALS['ecs']->table('category') .
"WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
并添加函数
function get_assign_child_tree($tree_id = '')
{
$three_arr = array();
if($tree_id == '') return $three_arr;
$child_sql = 'SELECT cat_id, cat_name, parent_id, is_show, assign_child, jump_url ' .
'FROM ' . $GLOBALS['ecs']->table('category') .
"WHERE cat_id in( $tree_id ) AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
$res = $GLOBALS['db']->getAll($child_sql);
foreach ($res AS $row)
{
if ($row['is_show'])
$three_arr[$row['cat_id']]['id'] = $row['cat_id'];
$three_arr[$row['cat_id']]['name'] = $row['cat_name'];
if(isset($row['jump_url']) != NULL && trim($row['jump_url']) != ''){
$three_arr[$row['cat_id']]['url'] = $row['jump_url'];
}else{
$three_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
}
if (isset($row['cat_id']) != NULL)
{
if(isset($row['assign_child']) != NULL && trim($row['assign_child']) != ''){
$three_arr[$row['cat_id']]['cat_id'] = get_assign_child_tree($row['assign_child']);
}else{
$three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
}
}
}
return $three_arr;
}
3、admin/category.php中作如下修改
在($_REQUEST['act'] == 'insert')、if ($_REQUEST['act'] == 'update')的条件中的
$cat['grade'] = !empty($_POST['grade']) ? intval($_POST['grade']) : 0;
$cat['filter_attr'] = !empty($_POST['filter_attr']) ? implode(',', array_unique(array_diff($_POST['filter_attr'],array(0)))) : 0;
后面添加
$cat['jump_url'] = !empty($_POST['jump_url']) ? trim($_POST['jump_url']) : '';
$cat['assign_child'] = !empty($_POST['assign_child']) ? trim($_POST['assign_child']) : '';
4、在admin/templates/category_info.htm的
<tr id="assign_child">
<td class="label">{$lang.assign_child}:</td>
<td>
<input type="text" name='assign_child' value='{$cat_info.assign_child}' size="32" />
</td>
</tr>
中添加
<tr id="jump_url">
<td class="label">{$lang.jump_url}:</td>
<td>
<input type="text" name='jump_url' value='{$cat_info.jump_url}' size="32" />
</td>
</tr>
5、languages/zh-cn/admin/category.php中添加如下语言描述
$_LANG['jump_url']='跳转url(指定跳转至的url)';
$_LANG['assign_child']='指定子类(将其id填写在输入框中即可,多个是用应为的“,”号隔开)';
(责任编辑:chinab4c) |
最近更新
常用插件
- ecshop2.7.1邮件发送插件
ecshop2.7.1邮件发送插件:该插件主要的开发思想是源于ecshop短信发送系统...
- ecshop2.7.2生成虚拟订单2.
以前我们开发过ecshop下的虚拟订单,就是客户在访问的时候,会自动生...
- ecshop没登陆情况下订单查
ecshop没登陆情况下订单查询插件,主要是针对ecshop在没有登陆的情况下...
- ecshop二次开发商品购买增
图片1香...
- ecshop最小购买数量控制插
ecshop最小购买数量控制插件,这个插件主要是为我们提供一个十分方便...
ecshop热门问答
ecshop热门资料
ecshop购物车详情
ecshop会员留言
ecshop放入回收站
ecshopOut
ecshop站点地图
ecshop详细内容
ecshop1wshop
ecshop市场价格
ecshop华文
ecshop商品团购超值礼包出错
ecshop佼佼者
ecshop货到付款?
ecshop经常
最土注册
ecshop开发者
ecshop追究
ecshopECSHOP二次开发
ecshop成功率
ecshopJPEG
ecshop客人
ecshop入侵
ecshop重写
ecshop礼品安全套
ecshoplock
ecshop分布式
ecshop如何赚
ecshop针对性
ecshop定单
ecshop习惯
ecshope-mail