![zencart侧边导航点击一级目录展开二级目录 zencart侧边导航点击一级目录展开二级目录](https://image.shishitao.com:8440/aHR0cDovL2Jic21heC5pa2FmYW4uY29tL3N0YXRpYy9MM0J5YjNoNUwyaDBkSEF2ZDNkM0xuZDBiM3A2TG1OdmJTOTFjR3h2WVdSekx6RXpNRGt4Tnk4eExURXpNRGt4UmpBeU1qUXpOakE1TG1wd1p3PT0uanBn.jpg?w=700&webp=1)
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 ...
随机推荐
-
Android Studio同时打开多个项目
Android Studio的默认设置是打开第二个项目时,第一个项目就被自动关闭了,如果要同时打开多个项目,可以点击File->Settings,对Project Opening进行下面的设置: ...
-
Egret白鹭H5小游戏开发入门(三)
前言: 在上一篇文章中着重介绍了H5小游戏开发的起步阶段,如Wing面板的使用,素材的处理,类的说明等等,那么今天主要是涉及到场景的创建,loading的修改等等的代码编写. 对于这一节,我在讲解的过 ...
-
微信小程序管理后台介绍
微信小程序的管理后台,每次进入都需要扫码,还是特别不爽,现在微信小程序还没正式发布,很多人都还没看到管理后台,这里抢先发布出来 ------------------------------------ ...
-
boost.asio源码剖析(一) ---- 前 言
* 前言 源码之前,了无秘密. ——侯捷 Boost库是一个可移植.提供源代码的C++库,作 ...
-
C/C++:Unions 联合
原文:http://msdn.microsoft.com/en-us/library/5dxy4b7b(v=vs.80).aspx 联合是用户定义的数据或类类型,在任何时间里,它只包含成员列表中的一个 ...
-
Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因
原文:Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因 今天试了下在虚拟机上利用CentOS系统的yum命令安装好了httpd(apache2.4.6), ...
-
蓝桥杯比赛javaB组练习《生日蜡烛》
题目如下: 生日蜡烛 某君从某年开始每年都举办一次生日party,并且每次都要吹熄与年龄相同根数的蜡烛. 现在算起来,他一共吹熄了236根蜡烛. 请问,他从多少岁开始过生日party的? 请填写他开始 ...
-
WebApi返回的Json去掉XML
在global.asax.cs文件中的 application_start()方法中加入下面一句话 GlobalConfiguration.Configuration.Formatters.XmlFo ...
-
java的缓存框架
1.java里面有一些开源的缓存框架,比如ecache,memcache,redis等缓存框架. 2.使用缓存框架的原理就是减少数据库端的压力,将缓存数据放在内存里面,存储成键值对的格式,这样可以不去 ...
-
gradle 插件
1. 系统内置插件的应用 a. 二进制 apply plugin :"pluginname" 比如: java b. 脚本插件 apply from : "version ...