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

Hidden Categories

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 10-13-2004, 09:31 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

For 4.0 the code is basically the same. Here's the code for the categories.php

Open include/categories.php

$categories_data = 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 ".($current_area=="C" ? "order_by" : "category"));

Replace with:

$categories_data = 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' OR $sql_tbl[categories].avail='H' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));
Reply With Quote
  #12  
Old 11-02-2004, 02:48 PM
 
delphi delphi is offline
 

Senior Member
  
Join Date: Jul 2004
Posts: 185
 

Default

Jon,
I am trying to apply hidden category to my XCart 4.0 but I could not find any code from include/categories.php. This is the code of categories.php

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); ?>

Could you show me where to replace the code?
__________________
X-Cart Gold version 4.4.4
X-Cart directory /home/web/u/ugchweb/cart
PHP 5
MySQL server 5
Reply With Quote
  #13  
Old 12-01-2004, 08:19 PM
 
eleven eleven is offline
 

Senior Member
  
Join Date: Nov 2002
Location: Charlotte, NC, USA
Posts: 118
 

Default 4.0.7

This is the categories.php code for version 4.0.7

Change:
Code:
$search_condition = "AND avail='Y' AND (membership='".addslashes($user_account["membership"])."' OR membership='')";
to:
Code:
$search_condition = "AND avail='Y' OR $sql_tbl[categories].avail='H' AND (membership='".addslashes($user_account["membership"])."' OR membership='')";

Nice little mod. Thanks!
__________________
|| E L E V E N ||
Reply With Quote
  #14  
Old 12-02-2004, 10:51 PM
 
GM GM is offline
 

eXpert
  
Join Date: Mar 2004
Location: Canada
Posts: 293
 

Default

Very Nice Jon... Thank You
__________________
v. 4.0.14 (GM Style)
O.S. Linux
Build Your Own Diamond Ring
Reply With Quote
  #15  
Old 12-25-2004, 10:56 AM
 
GM GM is offline
 

eXpert
  
Join Date: Mar 2004
Location: Canada
Posts: 293
 

Default

I think this mod should be standard XCart issue, however, there is one bug. If you try to search by price in v.4.09 you will get a four mile long SQL error
__________________
v. 4.0.14 (GM Style)
O.S. Linux
Build Your Own Diamond Ring
Reply With Quote
  #16  
Old 01-16-2005, 09:30 PM
 
skyking skyking is offline
 

Member
  
Join Date: Mar 2004
Posts: 13
 

Default

that should be handy for seperating some products out of the normal categories list. Thanks!
__________________
X-Cart gold 4.1.9
Reply With Quote
  #17  
Old 01-18-2005, 07:24 PM
 
markwhoo markwhoo is offline
 

X-Adept
  
Join Date: Nov 2003
Posts: 799
 

Default

Jon

I am trying to do something like this but with embedded pages.

I would like to create a few embedded pages to link via hyperlinks, but not be visable under the help section.

Is there something that could achive this as you have done here with the catagories?

Thanks in advance
__________________
vs 4.1.12
Reply With Quote
  #18  
Old 01-19-2005, 03:43 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

I don't use embedded pages so I can't say for sure.

You could probably edit your help menu template file and put a conditional to now show a certain page id #.
Reply With Quote
  #19  
Old 01-19-2005, 03:56 PM
 
markwhoo markwhoo is offline
 

X-Adept
  
Join Date: Nov 2003
Posts: 799
 

Default

Quote:
Originally Posted by Jon
I don't use embedded pages so I can't say for sure.

You could probably edit your help menu template file and put a conditional to now show a certain page id #.

Thanks for the reply,

I will look at the template and see how it is called and see what I can do.

I thought there was a thread that actually spoke of this, and I cannot find it to save my life.

Thanks again
__________________
vs 4.1.12
Reply With Quote
  #20  
Old 01-19-2005, 04:11 PM
  Stephen Hatton's Avatar 
Stephen Hatton Stephen Hatton is offline
 

Senior Member
  
Join Date: Mar 2004
Location: Melbourne, Australia
Posts: 182
 

Default Hidden is the word you need to use - Hidden Static Pages

Hi All

Nice MOD Jon. I will look into trying it soon.

To Markwhoo and others:
Hidden Static Pages.

Here are some links on this topic:
http://forum.x-cart.com/viewtopic.php?t=13705&highlight=hidden+pages+hatto n

http://forum.x-cart.com/viewtopic.php?t=11602&highlight=

Note: Follow the links and view the examples. If you or anybody else is interested in my mods - email/pmail me and I will give you the details.

Regards
Ing. Stephen Hatton
__________________
Apache Linux V1.3.33
PERL version: 5.8.0
PHP version: 4.3.11
MySQL version: 4.0.22-standard
X-cart V4.0.17: Addons: X-PConfig, X-Giftreg, X-Fancycat, X-AOM
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:16 AM.

   

 
X-Cart forums © 2001-2020