zencart侧边导航点击一级目录展开二级目录

zen cart Categories默认的是只显示一级目录,当点开一级后才能展开二级目录等,若要让它把一级和二级并列展开,则要更改些东西。
includes\classes\category_tree.php替换这下面的 代码即可
<?php
/**
* category_tree Class.
*
* @package classes
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: category_tree.php 3041 2006-02-15 21:56:45Z wilt $
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
/**
* category_tree Class.
* This class is used to generate the category tree used for the categories sidebox
*
* @package classes
*/
class category_tree extends base {function zen_category_tree($product_type = "all") {
global $db, $cPath;
if($cPath != '') global $cPath_array;
if ($product_type != 'all') {
$sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
where type_master_type = " . $product_type . "";
$master_type_result = $db->Execute($sql);
$master_type = $master_type_result->fields['type_master_type'];
}
$this->tree = array();
if ($product_type == 'all') {
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.parent_id = 0
and c.categories_id = cd.categories_id
and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
and c.categories_status= 1
order by sort_order, cd.categories_name";
} else {
$categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
where c.parent_id = 0
and ptc.category_id = cd.categories_id
and ptc.product_type_id = " . $master_type . "
and c.categories_id = ptc.category_id
and cd.language_id=" . (int)$_SESSION['languages_id'] ."
and c.categories_status= 1
order by sort_order, cd.categories_name";
}
$categories = $db->Execute($categories_query, '', true, 150);
while (!$categories->EOF) {
if($cPath == '') $cPath_array[$i++]=$categories->fields['categories_id'];
$this->tree[$categories->fields['categories_id']] =
array( 'name' => $categories->fields['categories_name'],
'parent' => $categories->fields['parent_id'],
'level' => 0,
'path' => $categories->fields['categories_id'],
'image' => $categories->fields['categories_image'],
'next_id' => false);if (isset($parent_id)) {
$this->tree[$parent_id]['next_id'] = $categories->fields['categories_id'];
}$parent_id = $categories->fields['categories_id'];
if (!isset($first_element)) {
$first_element = $categories->fields['categories_id'];
}
$categories->MoveNext();
}
if (1) {
$new_path = '';
reset($cPath_array);
while (list($key, $value) = each($cPath_array)) {
//$new_path = '';
unset($parent_id);
unset($first_id);
if ($product_type == 'all') {
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.parent_id = " . (int)$value . "
and c.categories_id = cd.categories_id
and cd.language_id=" . (int)$_SESSION['languages_id'] . "
and c.categories_status= 1
order by sort_order, cd.categories_name";
} else {
/*
$categories_query = "select ptc.category_id as categories, cd.categories_name, c.parent_id, c.categories_image
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
where c.parent_id = '" . (int)$value . "'
and ptc.category_id = cd.categories_id
and ptc.product_type_id = '" . $master_type . "'
and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
and c.categories_status= '1'
order by sort_order, cd.categories_name";
*/
$categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
where c.parent_id = " . (int)$value . "
and ptc.category_id = cd.categories_id
and ptc.product_type_id = " . $master_type . "
and c.categories_id = ptc.category_id
and cd.language_id=" . (int)$_SESSION['languages_id'] ."
and c.categories_status= 1
order by sort_order, cd.categories_name";}
$rows = $db->Execute($categories_query);
if ($rows->RecordCount()>0) {
$new_path .= $value;
while (!$rows->EOF) {
$this->tree[$rows->fields['categories_id']] = array('name' => $rows->fields['categories_name'],
'parent' => $rows->fields['parent_id'],
'level' => $key+1,
'path' => $new_path . '_' . $rows->fields['categories_id'],
'image' => $categories->fields['categories_image'],
'next_id' => false);if (isset($parent_id)) {
$this->tree[$parent_id]['next_id'] = $rows->fields['categories_id'];
}$parent_id = $rows->fields['categories_id'];
if (!isset($first_id)) {
$first_id = $rows->fields['categories_id'];
}$last_id = $rows->fields['categories_id'];
$rows->MoveNext();
}
$this->tree[$last_id]['next_id'] = $this->tree[$value]['next_id'];
$this->tree[$value]['next_id'] = $first_id;
$new_path .= '_';
} else {
break;
}
}
}
$row = 0;
return $this->zen_show_category($first_element, $row);
}function zen_show_category($counter,$ii) {
global $cPath_array;$this->categories_string = "";
for ($i=0; $i<$this->tree[$counter]['level']; $i++) {
if ($this->tree[$counter]['parent'] != 0) {
$this->categories_string=""; //一二级目录排列不一致时,清空循环加载的空格
$this->categories_string .= CATEGORIES_SUBCATEGORIES_INDENT;
}
}if ($this->tree[$counter]['parent'] == 0) {
$cPath_new = 'cPath=' . $counter;
$this->box_categories_array[$ii]['top'] = 'true';
} else {
$this->box_categories_array[$ii]['top'] = 'false';
$cPath_new = 'cPath=' . $this->tree[$counter]['path'];
$this->categories_string .= CATEGORIES_SEPARATOR_SUBS;
}
$this->box_categories_array[$ii]['path'] = $cPath_new;if (isset($cPath_array) && in_array($counter, $cPath_array)) {
$this->box_categories_array[$ii]['current'] = true;
} else {
$this->box_categories_array[$ii]['current'] = false;
}// display category name
$this->box_categories_array[$ii]['name'] = $this->categories_string . $this->tree[$counter]['name'];// make category image available in case needed
$this->box_categories_array[$ii]['image'] = $this->tree[$counter]['image'];if (zen_has_category_subcategories($counter)) {
$this->box_categories_array[$ii]['has_sub_cat'] = true;
} else {
$this->box_categories_array[$ii]['has_sub_cat'] = false;
}if (SHOW_COUNTS == 'true') {
$products_in_category = zen_count_products_in_category($counter);
if ($products_in_category > 0) {
$this->box_categories_array[$ii]['count'] = $products_in_category;
} else {
$this->box_categories_array[$ii]['count'] = 0;
}
}if ($this->tree[$counter]['next_id'] != false) {
$ii++;
$this->zen_show_category($this->tree[$counter]['next_id'], $ii);
}
return $this->box_categories_array;
}
}
?>
zencart侧边导航点击一级目录展开二级目录的更多相关文章
- bootstrap导航条在手机上默认展开二级目录,必须用setTimeout才能实现
bootstrap导航条在手机上默认展开二级目录,必须用setTimeout才能实现 $(document).ready(function() { $('.dropdown').hover(funct ...
- .Net Core小技巧 - Swagger适配虚拟目录及二级目录
前言 随着前后端分离模式与微服务架构的出现,Web API变得越来越重要及普遍.而后出现的网关技术,使开发者更倾向于使用二级/多级目录来暴露Web API,一是暴露的端口更少,方便管理:二是在网关中可 ...
- nginx下如何l在网站目录的二级目录下url重写的方法
以我新项目为例子,该项目要求用laravel来做,因此我把整个项目丢到一个叫laravel的文件夹里面了,目录就变成c:/nginx/html/laravel了,然后发现只能通过localhost/l ...
- ztree 展开一级节点 | ztree只显示到二级目录
// 默认展开一级节点var nodes = tree.getNodesByParam("level", 0);for (var i = 0; i < nodes.lengt ...
- Hibernate中一级缓存和二级缓存使用详解
一.一级缓存二级缓存的概念解释 (1)一级缓存就是Session级别的缓存,一个Session做了一个查询操作,它会把这个操作的结果放在一级缓存中,如果短时间内这个 session(一定要同一个ses ...
- 有二级目录的IIS配置
当项目配置文件中配置了二级目录时,如下: <!--二级目录地址--> <add key="SecondCatalog" value="/hotel&qu ...
- mybatis 详解(九)------ 一级缓存、二级缓存
上一章节,我们讲解了通过mybatis的懒加载来提高查询效率,那么除了懒加载,还有什么方法能提高查询效率呢?这就是我们本章讲的缓存. mybatis 为我们提供了一级缓存和二级缓存,可以通过下图来理解 ...
- Mybatis第八篇【一级缓存、二级缓存、与ehcache整合】
Mybatis缓存 缓存的意义 将用户经常查询的数据放在缓存(内存)中,用户去查询数据就不用从磁盘上(关系型数据库数据文件)查询,从缓存中查询,从而提高查询效率,解决了高并发系统的性能问题. myba ...
- Hibernate一级缓存和二级缓存详解
(1)一级缓存 是Session级别的缓存,一个Session做了一个查询操作,它会把这个操作的结果放在一级缓存中,如果短时间内这个session(一定要同一个session)又做了同一个操作,那么h ...
随机推荐
- 关于prototype属性的理解
众所周知,prototype是一个属性对象,只要创建一个新函数,就会根据特定的规则为该函数创建一个prototype属性,这个属性指向函数的原型对象.在默认情况下,所有原型对象都会自动获得一个cons ...
- petstore-jdbc
拖了好多天,终于决定开始写作业了,搞了大半天的把软件安好. jdk(安装与环境配置) Tomcat(安装与环境配置) mysql(安装,同时配置图形化操作界面) eclipse for Javaee ...
- 查看使用了那种shell
cat /etc/shells root@OpenWrt:/www/cgi-bin# cat /etc/shells/bin/ash
- 一个Cmake的例子
命令查询列表:http://www.cmake.org/cmake/help/v3.2/manual/cmake-commands.7.html # # Official dependency num ...
- 获取输入设备的vid和pid
一.获取/dev/input/event16设备的vid和pid testhid.c #include <linux/types.h> #include <linux/input.h ...
- spring securiy使用总结
我们常见的几个功能: 注册后直接登录,并且remember-me这种在网上找到很多注册后登录的,但是remember-me没有.其实解决方案还是看源码比较方便.a. 装载authenticationM ...
- eclipse配置tomcat及修改tomcat默认根目录
1.安装eclipse for j2ee和tomcat: 2.下载tomcat对eclipse的插件:http://www.eclipsetotale.com/tomcatPlugin.html 下载 ...
- Checking the Calendar
Checking the Calendar time limit per test 1 second memory limit per test 256 megabytes input standar ...
- OpenCV 基础知识------图像创建、访问、转换
cvCreateImage函数-- Cxcore数组操作 创建头并分配数据 IplImage* cvCreateImage( CvSize size, int depth, int channels ...
- Loadrunner脚本录制注意事项(七)
1.手动走一遍被测业务,达到熟悉理解业务,注意是否和服务器有数据交互,为脚本是否需要关联做准备: 2.浏览器选择IE8/9较好,选择其他浏览器可能会有各种问题.(a.IE设置:内容-设置-去掉所有选项 ...