View Single Post
  #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