博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ecshop设置一个子类对应多个父类并指定跳转url的修改方法
阅读量:7220 次
发布时间:2019-06-29

本文共 3931 字,大约阅读时间需要 13 分钟。

 这是一篇记录在日记里面的技术文档,其实是对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的

        {$lang.assign_child}:                                

  中添加

        {$lang.jump_url}:                                

  5、languages/zh-cn/admin/category.php中添加如下语言描述

  $_LANG['jump_url']='跳转url(指定跳转至的url)';

  $_LANG['assign_child']='指定子类(将其id填写在输入框中即可,多个是用应为的“,”号隔开)';

本文转自秋楓博客园博客,原文链接:http://www.cnblogs.com/rwxwsblog/p/4617932.html,如需转载请自行联系原作者
你可能感兴趣的文章
Git 二分调试法,火速定位疑难Bug!
查看>>
ArcGIS Engine 编辑- ITask
查看>>
C#线程系列讲座(4):同步与死锁
查看>>
第一篇:初识ASP.NET控件开发_第一节:控件类及其继承关系
查看>>
闲话WPF之十四(WPF的数据处理 [1] )
查看>>
【旅行】生的活力——西塘晨曦。
查看>>
Objective-C:继承、分类(Category、extension)、协议(protocol),个人理解,仅供参考
查看>>
【原】最长上升子序列——动态规划
查看>>
美化Windows Mobile上的自定义数据表
查看>>
关于ExtJSExtender
查看>>
Android、iOS和Windows Phone中的推送技术
查看>>
常用正则表达式(分享)转载
查看>>
memcpy和memmove的区别
查看>>
Flume的Collector
查看>>
Silverlight 5 beta新特性探索系列:6.Silverlight 5新增低延迟声音效果类SoundEffect.支持wav音乐格式【附带源码实例】...
查看>>
HDOJ2032 ( 杨辉三角 )
查看>>
python标准库学习7
查看>>
TCP协议的三次握手过程
查看>>
http://www.cnblogs.com/mfrbuaa/p/4739636.html
查看>>
Windows 8鲜为人知的50个小技巧
查看>>