ECShop网店系统技术交流论坛's Archiver

myareaway 发表于 2009-2-25 08:26

东京商品分类代码+模板文件+三级分类 更新贴

[i=s] 本帖最后由 myareaway 于 2009-4-2 16:18 编辑 [/i]

不好意思最近太忙很少来论坛  因为很多人想要这个东西 所以趁有时间整理了下发上来
因为该模板用到了jqurey 和ec 本身transport.js ajax 文件冲突还是有待解决
该模板只是提供参考 不一定适合您的网站有可能造成 css冲突 关于jqurey冲突问题解决方案比较复杂布适合新人使用
因为这个东京涉及3级分类 所以分类获得扩展到3级 将下面代码 掩盖掉lib_goods.php 对应方法
差点忘了说 在你css里引入@import 'images/home.css';
images放在模板目录下
images目录下的js文件放在根目录js文件夹里[code]/**
* 获得指定分类同级的所有分类以及该分类下的子分类
*
* @access  public
* @param   integer     $cat_id     分类编号
* @return  array
*/
function get_categories_tree($cat_id = 0)
{
    if ($cat_id > 0)
    {
        $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'";
        $parent_id = $GLOBALS['db']->getOne($sql);
    }
    else
    {
        $parent_id = 0;
    }

    /*
     判断当前分类中全是是否是底级分类,
     如果是取出底级分类上级分类,
     如果不是取当前分类及其下的子分类
    */
    $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$cat_id' AND is_show = 1 ";
    if ($GLOBALS['db']->getOne($sql) || $parent_id == 0)
    {
        /* 获取当前分类及其子分类 */
        $sql = 'SELECT a.cat_id, a.cat_name, a.sort_order AS parent_order, a.cat_id, a.is_show,' .
                    'b.cat_id AS child_id, b.cat_name AS child_name, b.sort_order AS child_order ,' .
                                       
                    'c.cat_id AS child_child_id, c.cat_name AS child_child_name, c.sort_order AS child_child_order ' .
                'FROM ' . $GLOBALS['ecs']->table('category') . ' AS a ' .
                'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS b ON b.parent_id = a.cat_id AND b.is_show = 1 ' .
                                
                'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.parent_id = b.cat_id AND c.is_show = 1 ' .
                "WHERE a.parent_id = '$parent_id' ORDER BY parent_order ASC, a.cat_id ASC, child_order ASC";
    }
    else
    {
        /* 获取当前分类及其父分类 */
        $sql = 'SELECT a.cat_id, a.cat_name, b.cat_id AS child_id, b.cat_name AS child_name, b.sort_order, b.is_show ,'  .
                                       
                    'c.cat_id AS child_child_id, c.cat_name AS child_child_name, c.sort_order AS child_child_order ' .
                'FROM ' . $GLOBALS['ecs']->table('category') . ' AS a ' .
                'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS b ON b.parent_id = a.cat_id AND b.is_show = 1 '.
                'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.parent_id = b.cat_id AND c.is_show = 1 ' .
                "WHERE b.parent_id = '$parent_id' ORDER BY sort_order ASC";
    }
    $res = $GLOBALS['db']->getAll($sql);
//echo $sql;
    $cat_arr = array();
    foreach ($res AS $row)
    {
        if ($row['is_show'])
        {        
                        
            $cat_arr[$row['cat_id']]['id']   = $row['cat_id'];
            $cat_arr[$row['cat_id']]['name'] = $row['cat_name'];
            $cat_arr[$row['cat_id']]['url']  = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
               
            if ($row['child_id'] != NULL)
            {
                $cat_arr[$row['cat_id']]['children'][$row['child_id']]['id']   = $row['child_id'];
                $cat_arr[$row['cat_id']]['children'][$row['child_id']]['name'] = $row['child_name'];
                $cat_arr[$row['cat_id']]['children'][$row['child_id']]['url']  = build_uri('category', array('cid' => $row['child_id']), $row['child_name']);
                                
                                 if ($row['child_child_id'] != NULL)
                                {
                                 $cat_arr[$row['cat_id']]['children'][$row['child_id']]['children'][$row['child_child_id']]['id']  = $row['child_child_id'];  $cat_arr[$row['cat_id']]['children'][$row['child_id']]['children'][$row['child_child_id']]['name']  = $row['child_child_name'];  $cat_arr[$row['cat_id']]['children'][$row['child_id']]['children'][$row['child_child_id']]['url']  = build_uri('category', array('cid' => $row['child_child_id']), $row['child_child_name']);
                        
                                }
            }
        }
    }

    return $cat_arr;
}
[/code][attach]20663[/attach]

xxkxj 发表于 2009-2-25 08:28

顶个
:victory:

xxkxj 发表于 2009-2-25 08:29

怎么用,天下说明吧!!:hug:

xxkxj 发表于 2009-2-25 08:33

直接放到京东的目录下?

mzsq39 发表于 2009-2-25 09:01

太强悍了。当时仿的时候感觉这块乱乎就没整,用上了

myareaway 发表于 2009-2-25 09:18

这也能算强悍。。。 10分钟弄出来的

mzsq39 发表于 2009-2-25 09:19

:curse:夸你两句还这样了

myareaway 发表于 2009-2-25 09:20

:loveliness:

mecan 发表于 2009-2-25 09:44

非常不错,用在多色模板上可以吗?

myareaway 发表于 2009-2-25 10:09

跟模板没关系 明白JS怎么回事 想怎么用都可以

selys 发表于 2009-2-25 11:48

这个压缩包内的东西  不适合新手  只是提取了360网站上关于左侧分类的代码  这个还得自己融到模版里,楼主有时间的话,直接发布融入后的吧

oioishop 发表于 2009-2-25 13:25

的确 ,最好是发一个cate_tree.lbi文件

拜月小刀 发表于 2009-2-25 13:40

类似这种弹出的菜单非常多   用在ec里面也非常简单   楼主能共享 就不错了

myareaway 发表于 2009-2-25 14:20

这东西会做模板的看下就该知道怎么改拉 早上冲咖啡的时候弄得
关于改成模板文件 再说吧 最近抽不出时间

myareaway 发表于 2009-2-25 14:22

[b] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=307199&ptid=77217]13#[/url] [i]拜月小刀[/i] [/b]
这东西会做模板的看下就该知道怎么改拉 早上冲咖啡的时候弄得
关于改成模板文件 再说吧 最近抽不出时间

winyong 发表于 2009-2-26 06:40

建议做成模板文件吧。我不会弄:(

gufei1 发表于 2009-2-26 17:11

:victory:强悍!哈哈
我都打算放弃这个模板了......
强人出现,谢谢

xiaopeng10 发表于 2009-2-26 17:21

這功能 真的不錯 是很喜歡的東東了 myareaway 可以抽時間的話 非常的感激了

samsiu 发表于 2009-2-27 09:27

好,正好用上

newkernel 发表于 2009-2-27 10:36

楼主这个不知道哪里下载人家的js文件,然后在这里拽。车······估计他自己也不是很懂所以想放上去看谁会弄帮他弄吧。想免费弄的找我吧,ec精神免费发。

selys 发表于 2009-2-27 10:44

[quote]楼主这个不知道哪里下载人家的js文件,然后在这里拽。车······估计他自己也不是很懂所以想放上去看谁会弄帮他弄吧。想免费弄的找我吧,ec精神免费发。
[size=2][color=#999999]newkernel 发表于 2009-2-27 10:36[/color] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=308184&ptid=77217][img]http://bbs.ecshop.com/images/common/back.gif[/img][/url][/size][/quote]




我权限不够  好象都不能给你发站内信~ 我想要一个[email=.wjselys@sohu.com].wjselys@sohu.com[/email]

fangyong 发表于 2009-2-27 12:58

[quote]楼主这个不知道哪里下载人家的js文件,然后在这里拽。车······估计他自己也不是很懂所以想放上去看谁会弄帮他弄吧。想免费弄的找我吧,ec精神免费发。
[size=2][color=#999999]newkernel 发表于 2009-2-27 10:36[/color] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=308184&ptid=77217][img]http://bbs.ecshop.com/images/common/back.gif[/img][/url][/size][/quote]
请你把这个做出来大家共享吧 ,我代表论坛上需要这个功能的朋友谢谢你了!

myareaway 发表于 2009-2-27 13:52

恩 我不懂 只会拖车 你厉害你来弄 真有意思:curse: 3天内你要是弄不出来 我弄 下周正好工作结束
你这人真让我火大

selys 发表于 2009-2-27 13:54

各位前辈~谢谢~

sibish 发表于 2009-2-27 14:10

不错,京东的模板越来越完善了。

bobo311 发表于 2009-2-27 14:56

太棒了,太感谢你了!

gufei1 发表于 2009-2-28 08:43

我觉得大家都是交流,首先楼主发出JS就已经很有共享精神.

winyong 发表于 2009-3-4 12:48

[quote]恩 我不懂 只会拖车 你厉害你来弄 真有意思:curse: 3天内你要是弄不出来 我弄 下周正好工作结束
你这人真让我火大
[size=2][color=#999999]myareaway 发表于 2009-2-27 13:52[/color] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=308322&ptid=77217][img]http://bbs.ecshop.com/images/common/back.gif[/img][/url][/size][/quote]

5天了....

rune1578 发表于 2009-3-5 00:19

激将法挺好使啊~~看来混论坛还得熟读孙子兵法啊~

xxkxj 发表于 2009-3-6 08:48

希望楼主尽快修改!!!

页: [1] 2 3 4

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.