Production Site: Zen Cart Ver 1.51
Testing Site: Zen Cart Ver 1.54
I'm currently testing the "Flyout Menu Categories" Add-On.
http://www.zen-cart.com/downloads.php?do=file&id=1
Since the support topic is closed. So, I am posting here.
If there is another topic exist, then please redirect me there.
Problem:
I am currently try out the flyout menu. It works fine, except that it listed ALL TYPES of Categories in same box!
I wanted to make it separate like how categories originally works (Like how Documents and Product Categories in two separate boxes)
Testing Site: http://homepromedical.com/zc154_test/
It seems it has to do with categories_tree.php vs categories_ui_generator.php
categories_ui_generator.php
Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: categories_ul_generator.php 2004-07-11 DrByteZen $
// based on site_map.php v1.0.1 by networkdad 2004-06-04
// Fix for line 48 provided by Paulm, uploaded by Kelvyn
class zen_categories_ul_generator {
var $root_category_id = 0,
$max_level = 6,
$data = array(),
$root_start_string = '',
$root_end_string = '',
$parent_start_string = '',
$parent_end_string = '',
$parent_group_start_string = '<ul%s>',
$parent_group_end_string = "</ul>",
$child_start_string = '<li%s>',
$child_end_string = "</li>",
$spacer_string = '',
$spacer_multiplier = 1;
var $document_types_list = ' (3) '; // acceptable format example: ' (3, 4, 9, 22, 18) '
function zen_categories_ul_generator($load_from_database = true) {
global $languages_id, $db;
$this->data = array();
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and c.categories_status=1 " .
// "and c.categories_id = ptc.category_id " .
// "and ptc.category_id = cd.categories_id " .
// "and ptc.product_type_id not in " . $this->document_types_list . "
" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
order by c.parent_id, c.sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
while (!$categories->EOF) {
$this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
$categories->MoveNext();
}
//DEBUG: These lines will dump out the array for display and troubleshooting:
//foreach ($this->data as $pkey=>$pvalue) {
// foreach ($this->data[$pkey] as $key=>$value) { echo '['.$pkey.']'.$key . '=>' . $value['name'] . '<br>'; }
//}
}
function buildBranch($parent_id, $level = 0, $submenu=false, $parent_link='') {
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
if (($this->data[$parent_id])) {
foreach ($this->data[$parent_id] as $category_id => $category) {
$category_link = $parent_link . $category_id;
if (($this->data[$category_id])) {
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
if (($this->data[$category_id]) && ($submenu==false)) {
$result .= sprintf($this->parent_start_string, ($submenu==true) ? ' class="level'.($level+1) . '"' : '');
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
$result .= sprintf($this->child_start_string, '');
}
}
if ($level == 0) {
$result .= $this->root_start_string;
}
$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
$result .= $category['name'];
$result .= '</a>';
if ($level == 0) {
$result .= $this->root_end_string;
}
if (($this->data[$category_id])) {
$result .= $this->parent_end_string;
}
if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
$result .= $this->buildBranch($category_id, $level+1, $submenu, $category_link . '_');
}
$result .= $this->child_end_string;
}
}
$result .= $this->parent_group_end_string;
return $result;
}
function buildTree($submenu=false) {
return $this->buildBranch($this->root_category_id, '', $submenu);
}
}
?>
categories_tree.php
Code:
<?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, $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) {
$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 (zen_not_null($cPath)) {
$new_path = '';
reset($cPath_array);
while (list($key, $value) = each($cPath_array)) {
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 .= 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;
}
}
?>
I am wonder which part of the code responsible to determine the type of categories, so the boxes can be split up.
Sincerely, PanZC2020 (May 12th, 2015)
Bookmarks