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

How do I display all subcategories along with all products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-04-2006, 05:48 PM
 
pwd88 pwd88 is offline
 

Advanced Member
  
Join Date: Dec 2004
Posts: 80
 

Default How do I display all subcategories along with all products

How do I display all subcategories along with all products under each subcategory on one page, here is what I want to do:
1 root category, has 2 subcategories, when customer clicks on root category, the subcategories.tpl displays 2 lines listed 2 subcategories, which is pretty ugly, I want it to dispaly like the following:
subcategory1
product1 under subcategory1
product2 under subcategory1
product3 under subcategory1
....
subcategory2
product1 under subcategory2
product2 under subcategory2
.....

Thanks in advance if you can point me into a right direction
__________________
XCart 4.0.18 Gold
X-Giftregistry
Neon light
Fashion mosaic
Tabbed product menu
Reply With Quote
  #2  
Old 02-28-2006, 08:25 AM
 
btomasie btomasie is offline
 

Advanced Member
  
Join Date: Oct 2004
Posts: 80
 

Default

TTT. I am looking for the same exact thing. Did anyone contact you prvately by chance with a aolution? Or were you able to find something in another threads that solved this for you? Thanks!

Brian
__________________
X-Cart Gold v4.0.18 [unix]
- Easy Checkout module
- ezUpsell module
- CDSEO module

X-Cart Gold v4.1.11 [unix]
***38,000+ active products!
- CDSEO module
- Address Book module
- Reorder module
- Smart Search module

X-Cart Gold v4.4.2 [unix]
- in development now!
Reply With Quote
  #3  
Old 06-21-2006, 08:37 PM
 
DavidPFarrell DavidPFarrell is offline
 

Member
  
Join Date: Jun 2006
Posts: 11
 

Default

:: EDIT ::

Okay here's what I did and so far it seems to work:

The $products array gets defined in a code snippet at the bottom of $xcart_dir/products.php. I moved that code snippet into a new file $xcart_dir/products_by_catid.php and modified products.php to include the new file. Now I have the freedom to load a $products array any time I want. I simply set $cat then include products_by_catid.php. After I verified that this small change worked (i.e. hit reload and page still there), I then modified products.php to cycle through the $subcategories array and, for each subcategory, grab the products list and store it in a "products" field.

What would make this mod really nice would be a simple way to enable/disable it from the admin console. Any Ideas?

Also, the code snippet that I added to products.php could just as easily be placed in $xcart_dir/home.php instead, which may actually be a more appropriate place for it.

Feeback appreciated.

Thanx

-D
PS: Oh, and it would be nice to have another mod that would add the subcats for the subcats I might try that one later.

---
Here's a small test snippet and the file changes for the mod:

Test Snippet To Try In: $xcart_dir/skin1/customer/main/subcategories.tpl
Code:
{if $subcategories} <ul> {foreach from=$subcategories item=subcat} [*]{$subcat.category|escape} <ul> {foreach from=$subcat.products item=subproduct} {if $subproduct} [*]{$subproduct.product|escape} {/if} {/foreach} [/list] {/foreach} [/list]{/if}

Create New File: $xcart_dir/products_by_catid.php
Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2006 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-2006 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: products.php,v 1.12 2006/01/11 06:55:57 mclap Exp $ # # Navigation code # if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); } # DavidPFarrell - This code was copied, unaltered, from $xcart_dir/products.php # # Get products data for current category and store it into $products array # $old_search_data = $search_data["products"]; $old_mode = $mode; $search_data["products"] = array(); $search_data["products"]["categoryid"] = $cat; $search_data["products"]["search_in_subcategories"] = ""; $search_data["products"]["category_main"] = "Y"; $search_data["products"]["category_extra"] = "Y"; $search_data["products"]["forsale"] = "Y"; if(!isset($sort)) $sort = $config["Appearance"]["products_order"]; if(!isset($sort_direction)) $sort_direction = 0; $mode = "search"; include $xcart_dir."/include/search.php"; $search_data["products"] = $old_search_data; $mode = $old_mode; if (!empty($active_modules["Subscriptions"])) { include $xcart_dir."/modules/Subscriptions/subscription.php"; } # /DavidPFarrell ?>

Modify File: $xcart_dir/products.php
Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2006 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-2006 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: products.php,v 1.12 2006/01/11 06:55:57 mclap Exp $ # # Navigation code # if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); } if ($config["General"]["disable_outofstock_products"] == "Y") { $avail = ($config["General"]["unlimited_products"] =="N")? " AND $sql_tbl[products].avail>0 " : ""; $current_category["product_count"] = func_query_first_cell ("SELECT COUNT(*) FROM $sql_tbl[products], $sql_tbl[products_categories] WHERE $sql_tbl[products].productid=$sql_tbl[products_categories].productid AND $sql_tbl[products].forsale='Y' $avail AND $sql_tbl[products_categories].categoryid='$cat'"); if (is_array($subcategories)) { foreach($subcategories as $k=>$v) { $subcategories[$k]["product_count"] = func_query_first_cell ("SELECT COUNT(*) FROM $sql_tbl[products], $sql_tbl[products_categories] WHERE $sql_tbl[products].productid=$sql_tbl[products_categories].productid AND $sql_tbl[products].forsale='Y' $avail AND $sql_tbl[products_categories].categoryid='$v[categoryid]'"); } $smarty->assign("subcategories",$subcategories); } } if ($active_modules["Advanced_Statistics"] && !defined("IS_ROBOT")) include $xcart_dir."/modules/Advanced_Statistics/cat_viewed.php"; # DavidPFarrell - Add a "products" field to each subcategory containing the array of products for that subcategory if (is_array($subcategories)) { $_oldcat = $cat; foreach ($subcategories as $_catid => $_subcat) { if (!empty($_catid)) { $cat = $_catid; $products = ""; include $xcart_dir."/products_by_catid.php"; if (is_array($products)) { $subcategories[$_catid]["products"] = $products; } } } $smarty->assign("subcategories",$subcategories); $cat = $_oldcat; } # /DavidPFarrell include $xcart_dir."/products_by_catid.php"; $smarty->assign("products",$products); $smarty->assign("navigation_script","home.php?cat=$cat&sort=$sort&sort_direction=$sort_direction"); ?>

=== Original Post ===
I could really use a response to this if anyone is out there?

It looks like "products.php" finds the product list via a specialized search. I was thinking we could do a similar thing within the loop that cycles through the sub-cats.

I was also thinking of trying to modify home.php and/or categories.php and/or products.php to create "subcat_products[subCatId]" (and possibly subcat_subcats[])

My concern with these is the extra function calls or includes changing variables that aren't needed for this mod but might be needed by other pages.

Ideas?
__________________
X-Cart v4.1.10 Gold
Reply With Quote
  #4  
Old 08-06-2007, 01:54 PM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default Re: How do I display all subcategories along with all products

I needed to add
Code:
$products = "";
after
Code:
$smarty->assign("subcategories",$subcategories); $cat = $_oldcat;
in your products.php custom routine.
Here's why:
If the category has no products but has multiple subcategories, and if the last category of those subcategories has products, the page would display these products twice. Once within the sub category and once underneath the category.
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote
  #5  
Old 10-25-2007, 09:41 AM
 
RobinBraves RobinBraves is offline
 

Advanced Member
  
Join Date: Oct 2005
Location: FL
Posts: 98
 

Default Re: How do I display all subcategories along with all products

Do you guys have a sample URL I could take a look at to see what this would look like?
__________________
Version 4.1.11
Reply With Quote
  #6  
Old 10-25-2007, 10:17 AM
 
RobinBraves RobinBraves is offline
 

Advanced Member
  
Join Date: Oct 2005
Location: FL
Posts: 98
 

Default Display SubCategory titles with products

I have searched through the forum and could not find anyone who has been able to implement this:

SubCategory Title
-------------------------------------------
product1 product2

product3 product4


SubCategory Title2
-------------------------------------------
product1 product2

product3 product4



Right now, it only shows products in the root category with all the SubCategory Titles above.
__________________
Version 4.1.11
Reply With Quote
  #7  
Old 10-26-2007, 04:11 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,470
 

Default Re: Display SubCategory titles with products

Do you mean on the crumb trail ?
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #8  
Old 10-26-2007, 09:45 AM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default Re: How do I display all subcategories along with all products

Here's a store that utilizes this custom mod: View Example Live Store
The store owner hasn't added many products yet but you should still be able to get a good idea of how it looks.
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote
  #9  
Old 10-26-2007, 09:48 AM
 
RobinBraves RobinBraves is offline
 

Advanced Member
  
Join Date: Oct 2005
Location: FL
Posts: 98
 

Default Re: How do I display all subcategories along with all products

Do you have the mod instructions for installation? I am using 4.1.8 and it does not apear to work for me with the instructions above.
__________________
Version 4.1.11
Reply With Quote
  #10  
Old 10-26-2007, 10:06 AM
 
RobinBraves RobinBraves is offline
 

Advanced Member
  
Join Date: Oct 2005
Location: FL
Posts: 98
 

Default Re: Display SubCategory titles with products

No, on the actual page.

I need it to appear like this sample:
http://www.jackmansfabrics.com/Bridal-Fabrics-p-1-c-294.html
__________________
Version 4.1.11
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


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 03:04 AM.

   

 
X-Cart forums © 2001-2020