东京商品分类代码+模板文件+三级分类 更新贴
[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] 顶个
:victory: 怎么用,天下说明吧!!:hug: 直接放到京东的目录下? 太强悍了。当时仿的时候感觉这块乱乎就没整,用上了 这也能算强悍。。。 10分钟弄出来的 :curse:夸你两句还这样了 :loveliness: 非常不错,用在多色模板上可以吗? 跟模板没关系 明白JS怎么回事 想怎么用都可以 这个压缩包内的东西 不适合新手 只是提取了360网站上关于左侧分类的代码 这个还得自己融到模版里,楼主有时间的话,直接发布融入后的吧 的确 ,最好是发一个cate_tree.lbi文件 类似这种弹出的菜单非常多 用在ec里面也非常简单 楼主能共享 就不错了 这东西会做模板的看下就该知道怎么改拉 早上冲咖啡的时候弄得
关于改成模板文件 再说吧 最近抽不出时间 [b] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=307199&ptid=77217]13#[/url] [i]拜月小刀[/i] [/b]
这东西会做模板的看下就该知道怎么改拉 早上冲咖啡的时候弄得
关于改成模板文件 再说吧 最近抽不出时间 建议做成模板文件吧。我不会弄:( :victory:强悍!哈哈
我都打算放弃这个模板了......
强人出现,谢谢 這功能 真的不錯 是很喜歡的東東了 myareaway 可以抽時間的話 非常的感激了 好,正好用上 楼主这个不知道哪里下载人家的js文件,然后在这里拽。车······估计他自己也不是很懂所以想放上去看谁会弄帮他弄吧。想免费弄的找我吧,ec精神免费发。 [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] [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]
请你把这个做出来大家共享吧 ,我代表论坛上需要这个功能的朋友谢谢你了! 恩 我不懂 只会拖车 你厉害你来弄 真有意思:curse: 3天内你要是弄不出来 我弄 下周正好工作结束
你这人真让我火大 各位前辈~谢谢~ 不错,京东的模板越来越完善了。 太棒了,太感谢你了! 我觉得大家都是交流,首先楼主发出JS就已经很有共享精神. [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天了.... 激将法挺好使啊~~看来混论坛还得熟读孙子兵法啊~ 希望楼主尽快修改!!!
