Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Drop down/flyout categories... where do I start?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #41  
Old 04-23-2004, 03:59 PM
 
danrwhit danrwhit is offline
 

Member
  
Join Date: Jan 2004
Posts: 16
 

Default

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
__________________
X-Cart version 3.4.11
Apache: 1.3.29
PHP: 4.3.4
MySQL: 4.0.17
Server: Red Hat 9
Reply With Quote
  #42  
Old 07-19-2004, 07:40 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

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.
Reply With Quote
  #43  
Old 07-19-2004, 10:06 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

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.
__________________
Current project: 4.4.2
Reply With Quote
  #44  
Old 07-20-2004, 12:47 AM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

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.
Reply With Quote
  #45  
Old 07-20-2004, 09:55 AM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

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
__________________
Current project: 4.4.2
Reply With Quote
  #46  
Old 07-21-2004, 03:34 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

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); }
Reply With Quote
  #47  
Old 07-21-2004, 03:46 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Moving to Custom Scripts ...
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #48  
Old 08-08-2004, 10:13 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

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);
?>
__________________
Current project: 4.4.2
Reply With Quote
  #49  
Old 08-09-2004, 09:21 PM
 
1320AutoSports 1320AutoSports is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 89
 

Default

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
Reply With Quote
  #50  
Old 08-09-2004, 09:25 PM
 
skyking skyking is offline
 

Member
  
Join Date: Mar 2004
Posts: 13
 

Default

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.
__________________
X-Cart gold 4.1.9
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020