当前位置:Gxlcms > PHP教程 > 【PHP开源产品】Ecshop的商品筛选功能实现分析之一(主要对category.php进行分析)_PHP教程

【PHP开源产品】Ecshop的商品筛选功能实现分析之一(主要对category.php进行分析)_PHP教程

时间:2021-07-01 10:21:17 帮助过:49人阅读

一、首先,说明一下为什么要对category.php文件进行分析。

(1)原因如下:

①个人对商城类商品筛选功能的实现比较好奇;

②对商城中关于商品的数据表设计比较感兴趣。(该功能涉及到与数据库的交互,而且与数据库中数据表的设计好坏有一定的联系);

③多条件(属性)筛选功能在现今的很多网站都需要用到,很广泛(如:一般商城网、团购网、房产网、信息分类网站等等)。

(2)希望达到的目的是:

①能够对多条件筛选功能有一个初步的认识。(起码自己做,也能够快速实现吧);

②对多条件筛选的实现中,数据库该如何去设计才会更优化和更合理些(参考前人的经验);

③对多条件筛选中的一些策略或者是技巧,能有一个了解(会总结几点)

二、然后,我们首先看一下现在需求是如何的?(多条件筛选,请参考京东、苏宁、国美等)

①京东商城的商品筛选功能(截图):

②苏宁商城的商品筛选功能(截图)

③国美在线的商品筛选功能(截图)

补充:其实,要对该功能的观察,还必须对地址栏,也作一番思考的,我这里就省略了,毕竟如果这样分析,会更简单一些。上面这些例子,只作一个引子吧。后续我会完善它的。

④ECSHOP的商品筛选功能实现,展示细节(截图+文字)如下:

1)首先,我本地服务器,给本机安装的ecshop演示网站,配了一个虚拟主机地址:为

“GSM手机”分类下的商品。如下:

如果我想查看品牌为“诺基亚”的手机,那么点击“诺基亚”标签即可:

访问地址为:

结果页面为:

访问地址为:

结果页面为:

分析:从上面的地址栏的变化和截图的变化,可以初步看出ecshop的多条件搜索方法是怎么样的了。

猜想1:随着用户每一次点击条件(属性)进行商品筛选时,搜索地址栏会变化,为什么地址栏会变化,归根结底,一定是每一个商品的属性的a标签的超链接地址被改变了。而且是每点击一次,都会随着搜索条件的不同,而改变。

从而我们知道,这个属性的超链接,是动态生成的。ecshop后台一定是作了大量的判断过程,并最终为每一个商品属性,生成一个超链接地址,以防止上一次的搜索条件丢失。

猜想2:商品的价格区间,是根据什么来计算的呢?还是人工后台设置的,京东的商品价格区间,好像都是很有规律的,和ecshop的价格区间,有比较大的区别。别管这么多了,我们还是先研究ecshop的再说。

猜想3:参数 filter_attr=163.0.160.0 中的几个数字,一定代表着下面:颜色、屏幕大小 、手机制式、外观样式属性下,都选择了哪一些值了。

----> 带着这样一些疑问,那我们直接去研究一下ecshop是如何实现上面的多条件搜索功能啦。。。GO。。。

首先,我们到ecshop的网站更目录,找到category.php文件,打开它进行研究一下。

('IN_ECS', (() . '/includes/init.php' ((DEBUG_MODE & 2) != 2 ->caching = 请求地址栏:http://localhost/category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 1.获取分类id ((['id' = (['id' ((['category' = (['category' } ecs_header("Location: ./\n" 2.首先获取所有GET和POST中,可用于搜索的参数的值。 若没有此参数,则说明,并没有用此参数来搜索,默认要给它一个默认值。 = (['page']) && (['page']) > 0 ? (['page']) : 1 = (['page_size']) && (['page_size']) > 0 ? (['page_size']) : 10 = (['brand']) && (['brand']) > 0 ? (['brand']) : 0 = (['price_max']) && (['price_max']) > 0 ? (['price_max']) : 0 = (['price_min']) && (['price_min']) > 0 ? (['price_min']) : 0 = (['filter_attr']) ? ((['filter_attr'])) : '0' = ( = () ? '' : ('.', ( = ['show_order_type'] == '0' ? 'list' : (['show_order_type'] == '1' ? 'grid' : 'text' = ['sort_order_method'] == '0' ? 'DESC' : 'ASC' = ['sort_order_type'] == '0' ? 'goods_id' : (['sort_order_type'] == '1' ? 'shop_price' : 'last_update' = ((['sort']) && (((['sort'])), ('goods_id', 'shop_price', 'last_update'))) ? (['sort']) : = ((['order']) && (((['order'])), ('ASC', 'DESC'))) ? (['order']) : = ((['display']) && (((['display'])), ('list', 'grid', 'text'))) ? (['display']) : ((['ECS']['display']) ? ['ECS']['display'] : = (, ('list', 'grid', 'text')) ? : 'text' ('ECS[display]', , gmtime() + 86400 * 7 = ('%X', ( . '-' . . '-' . .'-' . .'-' . . '-' . . '-' . ['user_rank'] . '-' . ['lang'] .'-'. . '-' . . '-' . . '-' . (!->is_cached('category.dwt', 3.把该栏目下的所有子栏目id获取,如果没有子栏目,则是自身。 TABLE:ecs_category RETURN:id=3 => g.cat_id IN ('3') 或 id=6 => g.cat_id IN ('6','8','9','11','7') 说明:ecshop的特点是,顶级栏目下也可以添加商品,所以会把顶级栏目id也放在数组里面 = get_children( 4.获得该分类的相关信息。如:分类名称、价格分级、筛选属性、父id TABLE:ecs_category RETURN:Array ( [cat_name] => GSM手机 [keywords] => [cat_desc] => [style] => [grade] => 4 [filter_attr] => 185,189,173,178 [parent_id] => 1 ) = get_cat_info( 5.如果有品牌筛选brand参数,那么获取出该品牌名称 TABLE:ecs_brand SQL:SELECT brand_name FROM `ecshop`.`ecs_brand` WHERE brand_id = '1' RETURN:诺基亚 ( > 0 = "SELECT brand_name FROM " .['ecs']->table('brand'). " WHERE brand_id = ''" = ->getOne( } = '' >================开始---商品价格区间处理==================>>/// 6.获取该分类cat的价格分级: ①如果价格分级=0,那么获取直接父类的价格分级。(Ⅰ如果父类价格也=0,那么就是不用价格分级 ) ②如果价格分级!=0,那么就是自身的价格分级。 TABLE:ecs_category RETURN:$cat['grade']=4 (['grade'] == 0 && ['parent_id'] != 0) { 如果价格分级为空,但是它还有上级分类,那么取直接上级的价格分级等数 ['grade'] = get_parent_grade(); 7.对价格区间进行划分。 ecshop的划分方法,是根据算法来的,比较复杂。 如果价格分级>1,那么就执行价格区间划分 (['grade'] > 1 获得当前分类下商品价格的最大值、最小值 获得所有扩展分类属于指定分类的所有商品ID ,其中goods_id = 16的商品的扩展属于分类3 TABLE:ecs_goods 和 ecs_goods_cat SQL:SELECT min(g.shop_price) AS min, max(g.shop_price) as max FROM `ecshop`.`ecs_goods` AS g WHERE (g.cat_id IN ('5') OR g.goods_id IN ('8','16') ) AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 RETURN:Array ( [min] => 280.00 [max] => 5999.00 ) = "SELECT min(g.shop_price) AS min, max(g.shop_price) as max ". " FROM " . ->table('goods'). " AS g ". " WHERE ( OR " . get_extension_goods() . ') AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 ' = ->getRow( 按照公式计算出最低价格和最高价格、以及价格跨度 = 0.0001 (=-2; <= (['max']); ++ *= 10 = ((['max'] - ['min']) / (['grade']) / ) * ( == 0 = ( = 1; ['min'] > * ; ++ ( = 1; ['min'] > * (-1) + * ; ++ ['min'] = * (-1) + * ( - 1 (; ['max'] >= * ; ++ ['max'] = * () + * ( - 1 这里打印最高价格和最低价格:$row=>Array ( [min] => 200 [max] => 6200 ) 这里打印价格跨度:$dx = 1500 根据商品的价格、价格区间的最低价格、以及价格跨度,计算该商品价格属于哪一个区间内。 获取属于该价格区间内的商品的数量、获取sn则属于哪一个区间sn=0为200-1700、sn=1为1700-3200、sn=3为4700-6200。 因为没有商品价格属于第二区间,则不存在sn=2,那么3200-4700则没有任何商品 TABLE:ecs_goods 和 ecs_goods_cat SQL:SELECT (FLOOR((g.shop_price - 200) / 1500)) AS sn, COUNT(*) AS goods_num FROM `ecshop`.`ecs_goods` AS g WHERE (g.cat_id IN ('3') OR g.goods_id IN ('16') ) AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 GROUP BY sn RETURN:Array ( [0] => Array ( [sn] => 0 [goods_num] => 6 ) [1] => Array ( [sn] => 1 [goods_num] => 5 ) [2] => Array ( [sn] => 3 [goods_num] => 1 ) ) = "SELECT (FLOOR((g.shop_price - [min]) / )) AS sn, COUNT(*) AS goods_num ". " FROM " . ->table('goods') . " AS g ". " WHERE ( OR " . get_extension_goods() . ') AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 '. " GROUP BY sn " = ->getAll( 根据价格等级price_grade,计算真正的价格区间。 方法build_uri()重要:要为每一个价格区间,生成一个url超链接,以备前台点击搜索用 并根据价格参数,判断该区间,是否是当前被搜索的区间 把价格区间,注入模板,供前台使用 RETURN:Array ( [0] => Array ( [sn] => 0 [goods_num] => 6 [start] => 0 [end] => 0 [price_range] => 全部 [url] => category.php?id=3&brand=1&price_min=0&price_max=0&filter_attr=163.216.160.186 [selected] => 0 ) [1] => Array ( [sn] => 1 [goods_num] => 6 [start] => 200 [end] => 1700 [price_range] => 200 - 1700 [formated_start] => ¥200元 [formated_end] => ¥1700元 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 1 ) [2] => Array ( [sn] => 3 [goods_num] => 5 [start] => 1700 [end] => 3200 [price_range] => 1700 - 3200 [formated_start] => ¥1700元 [formated_end] => ¥3200元 [url] => category.php?id=3&brand=1&price_min=1700&price_max=3200&filter_attr=163.216.160.186 [selected] => 0 ) [3] => Array ( [goods_num] => 1 [start] => 4700 [end] => 6200 [price_range] => 4700 - 6200 [formated_start] => ¥4700元 [formated_end] => ¥6200元 [url] => category.php?id=3&brand=1&price_min=4700&price_max=6200&filter_attr=163.216.160.186 [selected] => 0 ) ) ( => = + 1 []['goods_num'] = ['goods_num' []['start'] = ['min'] + ( * ['sn' []['end'] = ['min'] + ( * (['sn'] + 1 []['price_range'] = []['start'] . ' - ' . []['end' []['formated_start'] = price_format([]['start' []['formated_end'] = price_format([]['end' []['url'] = build_uri('category', ('cid'=>, 'bid'=>, 'price_min'=>[]['start'], 'price_max'=> []['end'], 'filter_attr'=>), ['cat_name' ((['price_min']) && []['start'] == && []['end'] == []['selected'] = 1 []['selected'] = 0 [0]['start'] = 0 [0]['end'] = 0 [0]['price_range'] = ['all_attribute' [0]['url'] = build_uri('category', ('cid'=>, 'bid'=>, 'price_min'=>0, 'price_max'=> 0, 'filter_attr'=>), ['cat_name' [0]['selected'] = () ? 1 : 0 ->assign('price_grade', >================开始---商品品牌处理==================>>/// ???db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") 品牌筛选功能:把该栏目下(其中包括扩展分类下的商品),所有商品的品牌获取,但不能重复。 品牌下有商品并且商品状态正常,才能把该品牌取出。没有商品的品牌不能取出 TABLE:ecs_brand、ecs_goods 和 ecs_goods_cat SQL:SELECT b.brand_id, b.brand_name, COUNT(*) AS goods_num FROM `ecshop`.`ecs_brand`AS b, `ecshop`.`ecs_goods` AS g LEFT JOIN `ecshop`.`ecs_goods_cat` AS gc ON g.goods_id = gc.goods_id WHERE g.brand_id = b.brand_id AND (g.cat_id IN ('3') OR gc.cat_id IN ('3') ) AND b.is_show = 1 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC RETURN:Array ( [0] => Array ( [brand_id] => 1 [brand_name] => 诺基亚 [goods_num] => 3 ) [1] => Array ( [brand_id] => 2 [brand_name] => 摩托罗拉 [goods_num] => 1 ) [2] => Array ( [brand_id] => 3 [brand_name] => 多普达 [goods_num] => 1 ) [3] => Array ( [brand_id] => 4 [brand_name] => 飞利浦 [goods_num] => 2 ) [4] => Array ( [brand_id] => 5 [brand_name] => 夏新 [goods_num] => 1 ) [5] => Array ( [brand_id] => 6 [brand_name] => 三星 [goods_num] => 2 ) [6] => Array ( [brand_id] => 7 [brand_name] => 索爱 [goods_num] => 1 ) [7] => Array ( [brand_id] => 9 [brand_name] => 联想 [goods_num] => 1 ) [8] => Array ( [brand_id] => 10 [brand_name] => 金立 [goods_num] => 1 ) ) = "SELECT b.brand_id, b.brand_name, COUNT(*) AS goods_num ". "FROM " . ['ecs']->table('brand') . "AS b, ". ['ecs']->table('goods') . " AS g LEFT JOIN ". ['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " . "WHERE g.brand_id = b.brand_id AND ( OR " . 'gc.cat_id ' . db_create_in((((), (cat_list(, 0, ))))) . ") AND b.is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC" = ['db']->getAll( 把该分类下所有商品的品牌,组合成数组,给前台调用 方法build_uri()重要:要为每品牌,生成一个url超链接,以备前台点击搜索用 把数组注入模板文件 Array ( [brand_id] => 1 [brand_name] => 全部 [goods_num] => 3 [url] => category.php?id=3&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [1] => Array ( [brand_id] => 2 [brand_name] => 诺基亚 [goods_num] => 1 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 1 ) [2] => Array ( [brand_id] => 3 [brand_name] => 摩托罗拉 [goods_num] => 1 [url] => category.php?id=3&brand=2&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [3] => Array ( [brand_id] => 4 [brand_name] => 多普达 [goods_num] => 2 [url] => category.php?id=3&brand=3&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [4] => Array ( [brand_id] => 5 [brand_name] => 飞利浦 [goods_num] => 1 [url] => category.php?id=3&brand=4&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [5] => Array ( [brand_id] => 6 [brand_name] => 夏新 [goods_num] => 2 [url] => category.php?id=3&brand=5&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [6] => Array ( [brand_id] => 7 [brand_name] => 三星 [goods_num] => 1 [url] => category.php?id=3&brand=6&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [7] => Array ( [brand_id] => 9 [brand_name] => 索爱 [goods_num] => 1 [url] => category.php?id=3&brand=7&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [8] => Array ( [brand_id] => 10 [brand_name] => 联想 [goods_num] => 1 [url] => category.php?id=3&brand=9&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) [9] => Array ( [brand_name] => 金立 [url] => category.php?id=3&brand=10&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 0 ) ) ( => = + 1 []['brand_name'] = ['brand_name' []['url'] = build_uri('category', ('cid' => , 'bid' => ['brand_id'], 'price_min'=>, 'price_max'=> , 'filter_attr'=>), ['cat_name' ( == []['brand_id' []['selected'] = 1 } []['selected'] = 0 [0]['brand_name'] = ['all_attribute' [0]['url'] = build_uri('category', ('cid' => , 'bid' => 0, 'price_min'=>, 'price_max'=> , 'filter_attr'=>), ['cat_name' [0]['selected'] = () ? 1 : 0 ->assign('brands', >==================开始---商品属性处理==================>>/// = ''; (['filter_attr'] > 0 需要筛选的属性,是人工在后台添加的,存放在ecs_category 表的中 filter_attr字段里面,格式如:185,189,120,190 RETURN:Array ( [0] => 185 [1] => 189 [2] => 173 [3] => 178 ) = (',', ['filter_attr']); 然后,对每一个属性(此属性是主属性,下面还有子属性),循环进行操作 ①获取该属性的属性名 ②获取该属性的所有子属性(子属性必须是有被商品在使用的,不然,不要将其显示出来) 意义:因为该属性涉及到搜索参数,如果该属性下本身没有商品,那么就没有显示出来的意义了。 RETURN: Array ( [0] => Array ( [attr_id] => 185 [goods_id] => 167 [attr_value] => 灰色 ) [1] => Array ( [attr_id] => 185 [goods_id] => 198 [attr_value] => 白色 ) [2] => Array ( [attr_id] => 185 [goods_id] => 197 [attr_value] => 金色 ) [3] => Array ( [attr_id] => 185 [goods_id] => 163 [attr_value] => 黑色 ) ) = ( => = "SELECT a.attr_name FROM " . ->table('attribute') . " AS a, " . ->table('goods_attr') . " AS ga, " . ->table('goods') . " AS g WHERE ( OR " . get_extension_goods() . ") AND a.attr_id = ga.attr_id AND g.goods_id = ga.goods_id AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND a.attr_id=''" ( = ->getOne( []['filter_attr_name'] = Array ( [attr_id] => 185 [goods_id] => 167 [attr_value] => 灰色 ) [1] => Array ( [attr_id] => 185 [goods_id] => 198 [attr_value] => 白色 ) [2] => Array ( [attr_id] => 185 [goods_id] => 197 [attr_value] => 金色 ) [3] => Array ( [attr_id] => 185 [goods_id] => 163 [attr_value] => 黑色 ) ) = "SELECT a.attr_id, MIN(a.goods_attr_id ) AS goods_id, a.attr_value AS attr_value FROM " . ->table('goods_attr') . " AS a, " . ->table('goods') . " AS g" . " WHERE ( OR " . get_extension_goods() . ') AND g.goods_id = a.goods_id AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 '. " AND a.attr_id='' ". " GROUP BY a.attr_value" = ->getAll( 163 [1] => 216 [2] => 160 [3] => 186 ) = ( = 0; < (); ++ [] = !([]) ? [] : 0 0 [1] => 216 [2] => 160 [3] => 186 ) [] = 0; = ('.', []['attr_list'][0]['attr_value'] = ['all_attribute' []['attr_list'][0]['url'] = build_uri('category', ('cid'=>, 'bid'=>, 'price_min'=>, 'price_max'=>, 'filter_attr'=>), ['cat_name' []['attr_list'][0]['selected'] = ([]) ? 1 : 0 Array ( [filter_attr_name] => 颜色 [attr_list] => Array ( [0] => Array ( [attr_value] => 全部 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=0.216.160.186 [selected] => 0 ) [1] => Array ( [attr_value] => 灰色 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=167.216.160.186 [selected] => 0 ) [2] => Array ( [attr_value] => 白色 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=198.216.160.186 [selected] => 0 ) [3] => Array ( [attr_value] => 金色 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=197.216.160.186 [selected] => 0 ) [4] => Array ( [attr_value] => 黑色 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 1 ) ) ) [1] => Array ( [filter_attr_name] => 屏幕大小 [attr_list] => Array ( [0] => Array ( [attr_value] => 全部 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.0.160.186 [selected] => 0 ) [1] => Array ( [attr_value] => 1.75英寸 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.229.160.186 [selected] => 0 ) [2] => Array ( [attr_value] => 2.0英寸 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 1 ) [3] => Array ( [attr_value] => 2.2英寸 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.223.160.186 [selected] => 0 ) [4] => Array ( [attr_value] => 2.6英寸 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.156.160.186 [selected] => 0 ) [5] => Array ( [attr_value] => 2.8英寸 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.200.160.186 [selected] => 0 ) ) ) [2] => Array ( [filter_attr_name] => 手机制式 [attr_list] => Array ( [0] => Array ( [attr_value] => 全部 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.0.186 [selected] => 0 ) [1] => Array ( [attr_value] => CDMA [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.202.186 [selected] => 0 ) [2] => Array ( [attr_value] => GSM,850,900,1800,1900 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 1 ) [3] => Array ( [attr_value] => GSM,900,1800,1900,2100 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.195.186 [selected] => 0 ) ) ) [3] => Array ( [filter_attr_name] => 外观样式 [attr_list] => Array ( [0] => Array ( [attr_value] => 全部 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.0 [selected] => 0 ) [1] => Array ( [attr_value] => 滑盖 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.199 [selected] => 0 ) [2] => Array ( [attr_value] => 直板 [url] => category.php?id=3&brand=1&price_min=200&price_max=1700&filter_attr=163.216.160.186 [selected] => 1 ) ) ) ) ( => = + 1 [] = ['goods_id']; = ('.', []['attr_list'][]['attr_value'] = ['attr_value' []['attr_list'][]['url'] = build_uri('category', ('cid'=>, 'bid'=>, 'price_min'=>, 'price_max'=>, 'filter_attr'=>), ['cat_name' (!([]) AND [] == ['goods_id']) { []['attr_list'][]['selected'] = 1 []['attr_list'][]['selected'] = 0 ->assign('filter_attr_list', (!( = "SELECT DISTINCT(b.goods_id) FROM " . ->table('goods_attr') . " AS a, " . ->table('goods_attr') . " AS b " . "WHERE " = ( => ) { (() && !=0 = . "b.attr_value = a.attr_value AND b.attr_id = " . [] ." AND a.goods_attr_id = " . = ->getColCached( .= ' AND ' . db_create_in(, 'g.goods_id' assign_template('c', ( 夏新_GSM手机_手机类型_ECSHOP演示站 - Powered by ECShop [ur_here] => 首页 > 手机类型 > GSM手机 > 夏新 ) = assign_ur_here(, ->assign('page_title', ['title']); ->assign('ur_here', ['ur_here']); ->assign('categories', get_categories_tree()); ->assign('helps', get_shop_help()); ->assign('top_goods', get_top10()); ->assign('show_marketprice', ['show_marketprice']); ->assign('category', ->assign('brand_id', ->assign('price_max', ->assign('price_min', ->assign('filter_attr', ->assign('feed_url', (['rewrite'] == 1) ? "feed-c.xml" : 'feed.php?cat=' . ); ( > 0 ['all'] = ('brand_id' => 0, 'brand_name' => ['_LANG']['all_goods'], 'brand_logo' => '', 'goods_num' => '', 'url' => build_uri('category', ('cid'=>), ['cat_name' } = = (, get_brands(, 'category' ->assign('data_dir', DATA_DIR); ->assign('brand_list', ->assign('promotion_info', get_promotion_info()); = (!( ->assign('vote_id', ['id' ->assign('vote', ['content' ->assign('best_goods', get_category_recommend_goods('best', , , , , ->assign('promotion_goods', get_category_recommend_goods('promote', , , , , ->assign('hot_goods', get_category_recommend_goods('hot', , , , , = get_cagtegory_goods_count(, , , , = (> 0) ? ( / ) : 1 ( > = = category_get_goods(, , , , , , , , ( == 'grid' (() % 2 != 0 [] = ->assign('goods_list', ); ->assign('category', ); ->assign('script_name', 'category'); assign_pager('category', , , , , , , '', , , , , ); assign_dynamic('category'); ->display('category.dwt', ?> 查看category.php全部代码

1)第一步,首先,文件一开头,一定是接收前台页面发送过来的各种POST和GET参数了,这里主要还是指地址栏GET方式传过来的参数了。

  2.首先获取所有GET和POST中,可用于搜索的参数的值。
  若没有此参数,则说明,并没有用此参数来搜索,默认要给它一个默认值。
 
  = (['page'])   && (['page'])  > 0 ? (['page'])  : 1  = (['page_size'])  && (['page_size']) > 0 ? (['page_size']) : 10  = (['brand']) && (['brand']) > 0 ? (['brand']) : 0  = (['price_max']) && (['price_max']) > 0 ? (['price_max']) : 0  = (['price_min']) && (['price_min']) > 0 ? (['price_min']) : 0  = (['filter_attr']) ? ((['filter_attr'])) : '0'  = (  = () ? '' : ('.', ( 
 
  = ['show_order_type'] == '0' ? 'list' : (['show_order_type'] == '1' ? 'grid' : 'text'  = ['sort_order_method'] == '0' ? 'DESC' : 'ASC'    = ['sort_order_type'] == '0' ? 'goods_id' : (['sort_order_type'] == '1' ? 'shop_price' : 'last_update' 
   = ((['sort'])  && (((['sort'])), ('goods_id', 'shop_price', 'last_update'))) ? (['sort'])  :   = ((['order']) && (((['order'])), ('ASC', 'DESC')))                              ? (['order']) :    = ((['display']) && (((['display'])), ('list', 'grid', 'text'))) ? (['display'])  : ((['ECS']['display']) ? ['ECS']['display'] :    = (, ('list', 'grid', 'text')) ?  : 'text' ('ECS[display]', , gmtime() + 86400 * 7);

3.把该栏目下的所有子栏目id获取,如果没有子栏目,

人气教程排行