X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Drop down/flyout categories... where do I start? (https://forum.x-cart.com/showthread.php?t=4502)

danrwhit 04-23-2004 03:59 PM

I really like the first one BOOMER, with the flyout DHTML. Is that only for the HTML catalog? Are you willing to share your code?

:P

xcell67 07-19-2004 07:40 PM

this mod is awesome, the new version 4.0.0 is awesome, this mod doesn't work with 4.0.0= not awesome

I think it has to do with Xcart upgrading Smarty that prevents this mod from working. Does anyone know how to use this with 4.0? If so please share your wisdom.

Cameron 07-19-2004 10:06 PM

Did you get it to work in 3.5.x? I managed to get it working in a 3.5.7 (or close to that) version. Had to go through categories.php *very* carefully and insert code from funky's version where needed. I'll post the categories.php for that site if you want, although I'm sure you'll have to do the same kind of thing for version 4, inserting the modified code where appropriate. If it's not categories.php though, I won't be much help to you.

xcell67 07-20-2004 12:47 AM

I had it working for 3.5.9, when I upgraded to 4.00, I didn't touch include/categories.php, customer/categories.tpl, or customer/dropdown.tpl.

Now the menu just shows all the categories instead of sliding out to the side. If you get it to work for 4.0, please let me know.

Cameron 07-20-2004 09:55 AM

That's a tricky one if your upgrade didn't change any of those files. I won't be going to version 4 for a while, and probably not with the site that I have the slide out menu on at all, so I won't be much help to you.

The best thing I can say would be to double check and make sure the upgrade process didn't change your categories.php/.tpl files, and once that is ruled out, trace the changes that occurred (or should have occurred) in the upgrade to see if there is something now *missing* from those 2 files that a clean install of version 4 would have. I'd bet there is. See if you can set up a clean install of a test site in version 4, then retro-fit this mod to it's categories.php

If it's smarty only, that's tough. But I have a feeling it's something else.

Cameron

xcell67 07-21-2004 03:34 PM

ok, i figured one thing out:

for skin1/customer/categories.tpl and skin1/customer/dropdown.tpl, you have to change all instances of:

$categories[cat_num].category_name

to

$categories[cat_num].category

and

$subcategories[cat_num].category_name

to

$subcategories[cat_num].category

The hard part is include/categories.php, the code is drastically different from the 3.5.x branch.

This is the include/categories.php for 4.0.0:

Code:

<?php
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart                                                                      |
| Copyright (c) 2001-2004 Ruslan R. Fazliev <rrf@rrf.ru>                      |
| All rights reserved.                                                        |
+-----------------------------------------------------------------------------+
| PLEASE READ  THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE  |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php                    |
|                                                                            |
| THIS  AGREEMENT  EXPRESSES  THE  TERMS  AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE  PROGRAM  AND  ASSOCIATED  DOCUMENTATION  THAT  RUSLAN  R. |
| FAZLIEV (hereinafter  referred to as "THE AUTHOR") IS FURNISHING  OR MAKING |
| AVAILABLE TO YOU WITH  THIS  AGREEMENT  (COLLECTIVELY,  THE  "SOFTWARE").  |
| PLEASE  REVIEW  THE  TERMS  AND  CONDITIONS  OF  THIS  LICENSE AGREEMENT |
| CAREFULLY  BEFORE  INSTALLING  OR  USING  THE  SOFTWARE.  BY INSTALLING, |
| COPYING  OR  OTHERWISE  USING  THE  SOFTWARE,  YOU  AND  YOUR  COMPANY |
| (COLLECTIVELY,  "YOU")  ARE  ACCEPTING  AND AGREEING  TO  THE TERMS OF THIS |
| LICENSE  AGREEMENT.  IF  YOU    ARE  NOT  WILLING  TO  BE  BOUND BY THIS |
| AGREEMENT, DO  NOT INSTALL OR USE THE SOFTWARE.  VARIOUS  COPYRIGHTS  AND |
| OTHER  INTELLECTUAL  PROPERTY  RIGHTS    PROTECT  THE  SOFTWARE.  THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES  YOU  LIMITED  RIGHTS  TO  USE |
| THE  SOFTWARE  AND  NOT  AN  AGREEMENT  FOR SALE OR FOR  TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT.      |
|                                                                            |
| The Initial Developer of the Original Code is Ruslan R. Fazliev            |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2004          |
| Ruslan R. Fazliev. All Rights Reserved.                                    |
+-----------------------------------------------------------------------------+
\*****************************************************************************/

#
# $Id: categories.php,v 1.64 2004/07/12 06:50:34 max Exp $
#

if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }

#
# Functions definition
#

#
# This function builds the categories list within specified category ($cat)
#
function func_get_categories_list($cat=0, $short_list=true, $flag=NULL) {
        global $current_area, $sql_tbl, $shop_language;
       
        $cat = intval($cat);
       
        $all_categories = array();
        $categories = array();
        $subcategories = array();

        $search_condition = "1";
       
        if ($flag == "root")
                $search_condition .= " AND parentid='0'";
        elseif ($flag == "level")
                $search_condition .= " AND parentid='$cat'";
               
        if ($current_area == "C") {
                global $user_account;
                $customer_search_condition = " AND avail='Y' AND (membership='".addslashes($user_account["membership"])."' OR membership='')";
                $search_condition .= $customer_search_condition;
                if ($flag == "all" || $flag == NULL)
                        $sort_condition = " ORDER BY category";
                else
                        $sort_condition = " ORDER BY order_by, category";
        }
       
        if ($short_list)
                $to_search = "categoryid,parentid,categoryid_path,category,product_count,avail,order_by";
        else
                $to_search = "*";
       
        if (defined('NEED_PRODUCT_CATEGORIES')) {
                global $productid;
                $to_search = explode(",", $to_search);
                foreach ($to_search as $k=>$v)
                        $to_search[$k] = $sql_tbl["categories"].".".$v;
                $to_search = implode(",", $to_search);
                $_categories = func_query("SELECT $to_search, $sql_tbl[products_categories].productid, $sql_tbl[products_categories].main FROM $sql_tbl[categories] LEFT JOIN $sql_tbl[products_categories] ON $sql_tbl[categories].categoryid=$sql_tbl[products_categories].categoryid AND $sql_tbl[products_categories].productid='$productid' GROUP BY $sql_tbl[categories].categoryid");
        }
        else
                $_categories = func_query("SELECT $to_search FROM $sql_tbl[categories] WHERE ".$search_condition.$sort_condition);

        if (is_array($_categories)) {
               
                $_category_names = array();
                if ($flag == "all" || $flag == NULL) {
                        foreach ($_categories as $k=>$v) {
                                $_category_names[$v["categoryid"]] = $v["category"];
                        }
                }
               
                foreach ($_categories as $k=>$category) {

                        if ($flag == "all" || $flag == NULL) {
                        #
                        # Get the full path for category name
                        #
                                $path = explode("/", $category["categoryid_path"]);
                                $category_path = array();
                                $continue = false;
                                foreach ($path as $i=>$catid) {
                                        if (empty($_category_names[$catid])) {
                                                $continue = true;
                                                break;
                                        }
                                        $category_path[] = $_category_names[$catid];
                                }
                                if ($continue)
                                        continue;
                                $category["category_path"] = implode("/",$category_path);

                        }
       
                        if ($current_area == "C") {
                        #
                        # Get the international category name
                        #
                                $int_res = func_query_first("SELECT category FROM $sql_tbl[categories_lng] WHERE code='$shop_language' AND categoryid='$category[categoryid]'");
                                if (!empty($int_res["category"]))
                                        $category["category"] = $int_res["category"];
                        }
               
                        #
                        # Count the subcategories for "root" and "level" flag values
                        #
                        if ($flag == "level" || $flag == "root" || $flag == NULL)
                                $category["subcategory_count"] = array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[categories] WHERE 1 $customer_search_condition AND categoryid!='$category[categoryid]' AND categoryid_path LIKE '$category[categoryid_path]/%'"));
                       
                        $all_categories[] = $category;
                        if (($flag == "root" || $flag == NULL) && $category["parentid"] == 0)
                                $categories[] = $category;
                        if (($flag == "level" || $flag == NULL) && $category["parentid"] == $cat)
                                $subcategories[] = $category;
                }

                if (($flag == "all" || $flag == NULL) and !empty($all_categories)) {
                        function func_categories_sort($a, $b) {
                                return strcmp($a["category_path"], $b["category_path"]);
                        }
                        usort($all_categories, "func_categories_sort");
                }
        }
       
        $return["all_categories"] = $all_categories;
        $return["categories"] = $categories;
        $return["subcategories"] = $subcategories;

        return $return;
}

#
# This function gathering the current category data
#
function func_get_category_data($cat) {
        global $current_area, $sql_tbl, $shop_language;
        global $xcart_dir, $current_location, $config;

        $cat = intval($cat);

        if ($current_area == "C")
                $search_condition = "AND avail='Y' AND (membership='".addslashes($user_account["membership"])."' OR membership='')";
       
        $category = func_query_first("SELECT * FROM $sql_tbl[categories] WHERE categoryid='$cat' $search_condition");

        if (!empty($category)) {

                #
                # Get the array of all parent categories
                #
                $_cat_sequense = explode("/", $category["categoryid_path"]);

                #
                # Generate category sequence, i.e.
                # Books, Books/Poetry, Books/Poetry/Philosophy ...
                #
                foreach ($_cat_sequense as $k=>$v) {
                        $_cat_name = array_pop(func_query_first("SELECT category FROM $sql_tbl[categories] WHERE categoryid='$v'"));
                        if ($current_area == "C") {
                        #
                        # Get the international category name for category location
                        #
                                $int_res = array_pop(func_query_first("SELECT category FROM $sql_tbl[categories_lng] WHERE code='$shop_language' AND categoryid='$v'"));
                                if (!empty($int_res["category"]))
                                        $_cat_name = $int_res["category"];
                        }

                        $category["category_location"][] = array($_cat_name, "home.php?cat=$v");
                }

                if ($current_area == "C") {
               
                        #
                        # Check if all parent categories are enabled
                        #
                        if (func_query_first_cell("SELECT COUNT(*) FROM $sql_tbl[categories] WHERE categoryid IN (".implode(",", $_cat_sequense).") AND avail='N'") > 0) {
                                return false;
                        }
                       
                        #
                        # Get the international category name and description
                        #
                        $int_res = func_query_first("SELECT * FROM $sql_tbl[categories_lng] WHERE code='$shop_language' AND categoryid='$cat'");
                        if (!empty($int_res["category"])) {
                                $category["category_name_orig"] = $category["category"];
                                $category["category"] = $int_res["category"];
                        }
                        if (!empty($int_res["description"]))
                                $category["description"] = $int_res["description"];
                }       
               
                if ($config["Images"]["icons_location"] == "FS")
                        $image_field = "image_path";
                else
                        $image_field = "image";
                       
                $_cat_sequense = array_reverse($_cat_sequense);
                foreach ($_cat_sequense as $k=>$v) {
                        $category_icon = func_query_first("SELECT $sql_tbl[icons].$image_field, $sql_tbl[categories].image_x, $sql_tbl[categories].image_y FROM $sql_tbl[icons], $sql_tbl[categories] WHERE $sql_tbl[icons].categoryid='$v'");
                        if (!empty($category_icon[$image_field])) {
                                $category["image_x"] = $category_icon["image_x"];
                                $category["image_y"] = $category_icon["image_y"];
                                break;
                        }
                }

                if ($config["Images"]["icons_location"] == "FS") {
                #
                # Correct the icon URL or path if icon is located in File system
                #
                        $category["image_path"] = $category_icon[$image_field];
                        if (eregi("^(http|ftp)://", $category["image_path"])) {
                        # image_path is an URL
                                $category["icon_url"] = $category["image_path"];
                        }
                        elseif (!strncmp($xcart_dir, $category["image_path"], strlen($xcart_dir))) {
                        # image_path is an locally placed image
                                $category["icon_url"] = $current_location.substr($category["image_path"], strlen($xcart_dir));
                        }
                }

                #
                # Count the subcategories
                #
                $category["subcategory_count"] = array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[categories] WHERE categoryid!='$cat' AND categoryid_path LIKE '$category[categoryid_path]/%' $search_condition"));
               
                return $category;
        }

        return false;
}

#
# Main code
#

$cat = intval($cat);


if ($cat > 0) {
#
# Get the current category data
#
        if ($current_category = func_get_category_data($cat))
                $smarty->assign("current_category", $current_category);
        else {
                if ($current_area == "A") {
                        $top_message["content"] = func_get_langvar_by_name("msg_category_not_exist");
                        $top_message["type"] = "E";
                        func_header_location("categories.php");
                }
                else
                        func_header_location("home.php");
        }
}


#
# Gather the array of categories and extract into separated arrays:
# $all_categories, $categories and $subcategories
#
if ($current_area == "C" or defined('MANAGE_CATEGORIES'))
        $_categories = func_get_categories_list($cat);
else
        $_categories = func_get_categories_list($cat, true, "all");

extract($_categories);


#
# Prepare data for FancyCategories module
#
if ($current_area == "C" and !empty($active_modules["Fancy_Categories"]))
        @include $xcart_dir."/modules/Fancy_Categories/fancy_categories.php";


$smarty->assign("allcategories", $all_categories);

$smarty->assign("categories", $categories);

if ($cat == 0)
        $subcategories = $categories;

if (!empty($subcategories))
        $smarty->assign("subcategories", $subcategories);

$smarty->assign("cat", $cat);

?>



Somehow somewhere, funky's codes need to be put in:

Code:

// funkydunk modification
// amended query to get the main cat and subcat for each record
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as maincat, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 2) as subcat from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));


and

Code:

                        // funkydunk code
  if(strstr($category_data["category"],"/")) {
      if ($category_data["category"] == $category_data["subcat"]){
      // echo "got one";
      // after taking off the initial category name this checks to see if this is only a sub category with no categories below it.
      // if i didn't do this the subcategory would be duplicated in the list
      $categories_data[$k]["subcatonly"]="true";
      }
  }
  // end of funkydunk amended code


$all_categories = $categories_data;
// func_print_r ($all_categories);
}


B00MER 07-21-2004 03:46 PM

Moving to Custom Scripts ...

Cameron 08-08-2004 10:13 PM

I received a request via pm for the categories.php I'm using on a 3.5.3 (or close to that) store for a fly out menu. Here it is.

Quote:

<?php
/************************************************** ***************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2004 Ruslan R. Fazliev <rrf@rrf.ru> |
| All rights reserved. |
+-----------------------------------------------------------------------------+
| PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php |
| |
| THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. |
| FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING |
| AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). |
| PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT |
| CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, |
| COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY |
| (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS |
| LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS |
| AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND |
| OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE |
| THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2004 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\************************************************* ****************************/

#
# $Id: categories.php,v 1.52.2.2 2004/02/05 12:25:46 mclap Exp $
#

if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }

if (empty($cat)) $cat = 0;

#
# For users some categories may be disabled
#

if ($current_area == "C" and !empty($user_account)) {
$membership_condition = " AND ($sql_tbl[categories].membership='$user_account[membership]' OR $sql_tbl[categories].membership='') ";
} else {
$membership_condition = " AND ($sql_tbl[categories].membership='') ";
}

// funkydunk modification
// amended query to get the main cat and subcat for each record
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as maincat, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 2) as subcat from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));


#
# Put all categories into $all_categories array and find current_category
# by categoryid stored in $cat
#
if(!$categories_data) $categories_data = array();

foreach($categories_data as $k=>$category_data) {
if ($current_area == "C") {
$int_res = func_query_first("SELECT * FROM $sql_tbl[categories_lng] WHERE code='$store_language' AND categoryid='$category_data[categoryid]'");
if (!empty($int_res["category"]))
$categories_data[$k]["category_name"] = $category_data["category_name"] = $int_res["category"];
if (!empty($int_res["description"]))
$categories_data[$k]["description"] = $category_data["description"] = $int_res["description"];

}
if ($category_data["categoryid"]==$cat) {
$current_category = $category_data;
}

// funkydunk code
if(strstr($category_data["category"],"/")) {
if ($category_data["category"] == $category_data["subcat"]){
// echo "got one";
// after taking off the initial category name this checks to see if this is only a sub category with no categories below it.
// if i didn't do this the subcategory would be duplicated in the list
$categories_data[$k]["subcatonly"]="true";
}
}
// end of funkydunk amended code

}

$all_categories = $categories_data;

#
#
#
if (!empty($active_modules["Fancy_Categories"]))
@include $xcart_dir."/modules/Fancy_Categories/fancy_categories.php";

#
# Put all root categories to $categories array
# Put all subcategories of current_category to $categories array
#
if (!empty($current_category))
$cur_dir_len = strlen($current_category["category"]);

foreach($all_categories as $all_category) {

$category=$all_category["category"];

if(!strstr($category,"/")) {
$categories[]=$all_category;
if(empty($current_category)) {
$subcategories[]=$all_category;
}
}

if(!empty($current_category) and substr($category,0,$cur_dir_len+1) == $current_category["category"]."/" and $category!=$current_category["category"])
if(!strstr(substr($category,$cur_dir_len+1),"/")) {
$all_category["category"]=ereg_replace("^.*/","",$all_category["category"]);
$subcategories[]=$all_category;
}

}


#
# Put subcategory_count to $subcategories array
#
if (!empty($subcategories))
foreach($subcategories as $key =>$subcategory) {

$subcategory["subcategory_count"]=0;

foreach($all_categories as $all_category) {
if ($all_category["categoryid"]==$subcategory["categoryid"]) {
$cur_dir_len = strlen($all_category["category"]);
$current_subcategory=$all_category["category"];
}
}

foreach($all_categories as $all_category) {
$category=$all_category["category"];
if(substr($category,0,$cur_dir_len+1) == $current_subcategory."/" and $category!=$current_subcategory)
if(!strstr(substr($category,$cur_dir_len+1),"/"))
$subcategory["subcategory_count"]++;
}
$subcategories[$key]["subcategory_count"]=$subcategory["subcategory_count"];
}

#
# Generate category sequence, i.e.
# Books, Books/Poetry, Books/Poetry/Philosophy ...
#

if (!empty($current_category)) {

$current_category_array = explode("/",$current_category["category"]);
$prev = $current_category_array[0];
list($key,$val)=each($current_category_array);

$new_array = array($val);

while(list($key,$val)=each($current_category_array )) {
$new_array[] = $prev."/".$val;
$prev = $prev."/".$val;
}
unset($current_category_array);

#
# Generate array for displaying categories sequence in location
#

$category_location=array();
reset($all_categories);

$my_cats = array ();

foreach($all_categories as $all_category) {

$categoryid=$all_category["categoryid"];
$category=$all_category["category"];

$my_cats [$categoryid] = $category;
}

asort ($my_cats);

foreach ($my_cats as $categoryid => $category) {
reset ($new_array);
while(list($key,$val)=each($new_array)) {
if ($val==$category) {
foreach($categories_data as $category_data) {
if ($category_data["categoryid"] == $categoryid)
$val = $category_data["category_name"];
}
$category_location[]=array(ereg_replace(".*/","",$val),"home.php?cat=".$categoryid);
}
}
}

}

if ($current_area == "C" and !empty($current_category) and $config["Images"]["icons_location"] == "FS") {
$current_category["image_path"] = array_pop(func_query_first("SELECT image_path FROM $sql_tbl[icons] WHERE categoryid='$cat'"));
if (eregi("^(http|ftp)://", $current_category["image_path"])) {
# image_path is an URL
$current_category["icon_url"] = $current_category["image_path"];
}
elseif (eregi($xcart_dir, $current_category["image_path"])) {

# image_path is an locally placed image
$current_category["icon_url"] = $http_location.ereg_replace($xcart_dir, "", $current_category["image_path"]);
}
}

#
# Assign Smarty variables
#

//print_r($all_categories);

$all_categories_cus = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by $sql_tbl[categories].category");

$smarty->assign("allcategories_cus",$all_categories_cus) ;
$smarty->assign("allcategories",$all_categories);
$smarty->assign("categories",$categories);
if (!empty($subcategories))
$smarty->assign("subcategories",$subcategories);
if (!empty($current_category))
$smarty->assign("current_category",$current_category);
$smarty->assign("cat",$cat);
?>


1320AutoSports 08-09-2004 09:21 PM

Well, I have been trying to get this booger to work with 4.0.1 for quite a while now (to not avail I shall add), but I am also new to this Smarty/PHP and SQL stuff. But I will give as much info as I can (I grasp onto stuff pretty quick).

Here is the original code by Funk
Code:

$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as maincat, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 2) as subcat from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));

If you look inside the categories.php in 4.0.x you will see that many of those things are not applicable (mostly due to this section):
Code:

function func_get_categories_list($cat=0, $short_list=true, $flag=NULL) {
        global $current_area, $sql_tbl, $shop_language, $active_modules;
       
        $cat = intval($cat);
       
        $all_categories = array();
        $categories = array();
        $subcategories = array();

        $search_condition = "1";
       
        if ($flag == "root")
                $search_condition .= " AND $sql_tbl[categories].parentid='0'";
        elseif ($flag == "level")
                $search_condition .= " AND $sql_tbl[categories].parentid='$cat'";
               
        if ($current_area == "C") {
                global $user_account;
                $customer_search_condition = " AND $sql_tbl[categories].avail='Y' AND ($sql_tbl[categories].membership='".addslashes($user_account["membership"])."' OR $sql_tbl[categories].membership='')";
                $search_condition .= $customer_search_condition;
                if ($flag == "all")
                        $sort_condition = " ORDER BY $sql_tbl[categories].category";
                else
                        $sort_condition = " ORDER BY $sql_tbl[categories].order_by, $sql_tbl[categories].category";
        }
        elseif (defined('MANAGE_CATEGORIES'))
                $sort_condition = " ORDER BY $sql_tbl[categories].category, $sql_tbl[categories].order_by";
       
        if ($short_list) {
                $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].product_count,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
        } else {
                $to_search = "$sql_tbl[categories].*";
        }

        $join_tbl = '';
        if ($current_area == "C") {
                $join_tbl .= " LEFT JOIN $sql_tbl[categories_lng] ON $sql_tbl[categories_lng].code='$shop_language' AND $sql_tbl[categories_lng].categoryid=$sql_tbl[categories].categoryid ";
                $to_search .= ",$sql_tbl[categories_lng].category as category_lng";
        }

        #
        # Count the subcategories for "root" and "level" flag values
        #
        if($flag == "level" || $flag == "root" || $flag == NULL) {
                $customer_search_condition = str_replace($sql_tbl["categories"], "subcat", $customer_search_condition);
                $join_tbl .= " LEFT JOIN $sql_tbl[categories] as subcat ON subcat.categoryid_path LIKE CONCAT($sql_tbl[categories].categoryid_path,'/%') AND $sql_tbl[categories].categoryid != subcat.categoryid ".$customer_search_condition;
                $to_search .= ",COUNT(subcat.categoryid) as subcategory_count";
        }
       
        if (defined('NEED_PRODUCT_CATEGORIES')) {
                global $productid;
                $_categories = func_query("SELECT $to_search, $sql_tbl[products_categories].productid, $sql_tbl[products_categories].main FROM $sql_tbl[categories] $join_tbl LEFT JOIN $sql_tbl[products_categories] ON $sql_tbl[categories].categoryid=$sql_tbl[products_categories].categoryid AND $sql_tbl[products_categories].productid='$productid' GROUP BY $sql_tbl[categories].categoryid");
        } else {
                $_categories = func_query("SELECT $to_search FROM $sql_tbl[categories] $join_tbl WHERE ".$search_condition." GROUP BY $sql_tbl[categories].categoryid ".$sort_condition);
        }


More things to note, in 4.0.x if you check out the SQL tables you will now see:
Code:

$sql_tbl[categories].parentid

which in the long run, may make this hack even easier (I just don't know how to do it).

You will not that the parentid will match the categoryid of the root category it belongs to.

So from what I understand we will need to modify Funks code to drop:
Code:

($sql_tbl[categories].membership='".addslashes($user_account["membership"])."' OR $sql_tbl[categories].membership='')";

Since it is defined when getting the value of $customer_search_condition

Also $category_data doesn't apply to us, we would have to modify that depending on which view setting you wanted to change, if you want it to be global, I believe you would have to create a completly new variable to have them all equal it (but again, this may be my ignorance talking).

Well, I have more findings, but I am dead tired and quite frankly all these letter and stuff give me a headache.. hopefully I didn't buther this up too much, like I said before, I am new to this :)

skyking 08-09-2004 09:25 PM

Cameron,
Thank you for posting that code. I am still getting nothing though, and will have to look it over some more. I had this working quickly on a 3.4.x demo store, but now no joy on the 3.5.8.

1320AutoSports 08-09-2004 09:39 PM

I just had another thought (I feel like Cosmo from the Fairly Oddparents, so sad, I wish I could say I was old enough to have kids, so I could blame it on them that I know caracters from cartoons on nick.).

Ok, so here are some more of my thoughts (beware):

I don't think the categories.php has to be changed at all, but ONLY the dropdown.tpl, home.tpl (to include the dropdown, DUH) and the categories.tpl. This is why..

In funks original code (again here):
Code:

// funkydunk modification
// amended query to get the main cat and subcat for each record
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as maincat, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 2) as subcat from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));


It seems to me all that is being done is verifying the category is avaliable, and the biggest thing is, this is where the values of maincat and subcat are defined, but in 4.0.x we have parentid, which also should mean we don't have to set the index's right? Or am I wrong?

If we need to define the SUBSTRINGS we can define them much simpler by going SUBSTRING_INDEX($sql_tbl[categories].categoryid ? or something like that, again my ignorance to programming is where I can not be helpful.

So here are some of my thoughts:. (note I am only putting up the modifying part of the dropdown.tpl)
Code:

{section name=cat_num loop=$categories}
{assign var="temp" value="0"}
{section name=cat loop=$allcategories}
{if $allcategories[cat].maincat eq $categories[cat_num].category}
{if $allcategories[cat].subcatonly}
{$temp}
{if $temp gt 0}
linkset[{$smarty.section.cat_num.index}] +='<div class="menuitems">{$allcategories[cat].category}</div>'
{else}
linkset[{$smarty.section.cat_num.index}] ='<div class="menuitems">{$allcategories[cat].category}</div>'
{/if}

{math equation="temp+1" temp=$temp assign=temp}
{/if}
{/if}
{/section}
{/section}


Would we just modify this section:
Code:

{if $allcategories[cat].maincat eq $categories[cat_num].category}
{if $allcategories[cat].subcatonly}


to say something like:
Code:

{if $allcategories[cat].categoryid eq $categories[cat_num].category}
{if $allcategories[cat_num].parentid}


or something along those lines.

We would also have to change the categories.tpl to match these changes..

Am I making any sense? Or am I on the wrong path to completion for 4.0.x? Thanks for pointing me in some kind of direction, because I feel like I am getting myself even more confused. Thanks

donavichi 08-10-2004 01:01 AM

Another quality mod from funkydunk!
-------------------------------------------

I've just implemented this and am really pleased with it, thanks, man!

I too have a question, however.....

How do you make the flyout menu flyout again, to display a sub-category's subcategories?

Answers on a postcard!

Many Thanks

Cameron 08-10-2004 09:13 AM

Finally a question that I can help with. :) The mod only provides for popping out one sub category -- to do more would significantly increase a page's load time and database stress. Funky said words to that effect waaaayyyy early in this thread somewhere.

Quote:

Originally Posted by donavichi
Another quality mod from funkydunk!
-------------------------------------------

I've just implemented this and am really pleased with it, thanks, man!

I too have a question, however.....

How do you make the flyout menu flyout again, to display a sub-category's subcategories?

Answers on a postcard!

Many Thanks


donavichi 08-10-2004 11:36 PM

OK Cool, thanks.

I didn't pick up on that because I was speed reading but I'm glad you cleared it up for me, good work.


Regards,

1320AutoSports 08-12-2004 09:33 PM

Anyone feel like helping me out? Just AIM me..

I think I have most of it figured out..

With how the 4.0.1 is, I am still going to have to do a substring index or try to explode the categoryid_path sql entry and do a if eq statement for those..

If someone wants to help me.. please let me know.

mlannen@tecconvt.net 08-17-2004 01:22 PM

NetScape & Mozilla Firefox Support?
 
I was curious if anyone has tried this Mod and tried viewing it in Netscape or Mozilla Firefox?

I tried Netscape 7.2 and Mozilla Firefox 0.8 and neither work properly with the popup menus. It kind of just overlaps the main category item. Hard to explain.

It works just fine in my IE 6.0. But a small amount of my clients use Netscape / Mac / Mozilla. I knoe they should prolly just use IE but....

ANy suggesstions??? Funkydunk? :)

THanks so much in advance!

`Mike
Using X-Cart 3.4.14 - Linux

1320AutoSports 08-17-2004 01:57 PM

Re: NetScape & Mozilla Firefox Support?
 
Quote:

Originally Posted by mlannen@tecconvt.net
I was curious if anyone has tried this Mod and tried viewing it in Netscape or Mozilla Firefox?

I tried Netscape 7.2 and Mozilla Firefox 0.8 and neither work properly with the popup menus. It kind of just overlaps the main category item. Hard to explain.

It works just fine in my IE 6.0. But a small amount of my clients use Netscape / Mac / Mozilla. I knoe they should prolly just use IE but....

ANy suggesstions??? Funkydunk? :)

THanks so much in advance!

`Mike
Using X-Cart 3.4.14 - Linux


I have a mod similar to this working on 4.0.1 and have tested with Firefox .9 and Konquror 3.2.3-2.kde Red Hat and it works just fine for both :)

If you could check www.mtgcardhouse.com/store for me with Nutscrape 6.x or 7.x that would be awesome :)

24md 09-15-2004 06:45 AM

Wow, this is a fantastic mod, I am ever grateful for this. I got it to work a treat in 3.5.7.

Just what I wanted.

BHMedia 09-17-2004 03:23 PM

Hey - How did you get it to work with 3.5.7? I have 3.5.7 and I can't get it to work on this one site - I get a java script error...

24md 09-18-2004 05:59 AM

Hey

I used funkydunk's code and instructions on the first page of this post. Just followed exactly what he said and it worked.

Then added the CSS code from page two to my skin.css file.

I will post my code if you want, but it is the same as his.

BHMedia 09-18-2004 08:13 AM

its weird - i followed every step and it doesnt work... hmm any ideas

24md 09-18-2004 11:12 AM

I'm only just getting to grips with xcart, so not that great with it, but post your web site address and I'll take a look.

BHMedia 09-18-2004 12:46 PM

let me go through all the steps again... if i cant get it I will ask for help :D I think that I was trying to get it to work on my 3.5.7 cart and it wasnt working not 100% sure tho... let me try it

adpboss 10-14-2004 04:17 PM

Could someone/anyone post some finished code here with version #'s?

It would be much appreciated.

brett 11-23-2004 09:02 PM

So anyone have this mod running right on 4.0? yet? uped to this version and so much different to me it's like starting over again 8O

brightway 01-25-2005 03:36 PM

I would also like to use this mod on 4.0.11.
Has anybody got it working on that version? or a version close to it?

Cheers.

Danielle 01-31-2005 11:20 AM

Will this work on the latest version of Pro?

PhilJ 09-23-2005 04:13 PM

http://forum.x-cart.com/viewtopic.php?p=107458

boomobile 06-26-2008 02:16 PM

Re: Drop down/flyout categories... where do I start?
 
I know this is an old thread, but has anyone put this on their site? I've got another inquiry in another thread...


All times are GMT -8. The time now is 05:53 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.