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

Showing a products subcat on the products page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-25-2005, 07:21 AM
 
sermad sermad is offline
 

Advanced Member
  
Join Date: May 2005
Posts: 39
 

Default Showing a products subcat on the products page

Hi guys.

How can I show the subcategory of a product on the products page?
__________________
Version 4.0.14
Reply With Quote
  #2  
Old 07-25-2005, 06:34 PM
  Dongan's Avatar 
Dongan Dongan is offline
 

X-Wizard
  
Join Date: Jul 2005
Location: www.mercuryminds.com
Posts: 1,531
 

Default

Hi,

I think this is what you are looking for...

http://forum.x-cart.com/viewtopic.php?t=5131
Reply With Quote
  #3  
Old 07-26-2005, 03:00 AM
 
sermad sermad is offline
 

Advanced Member
  
Join Date: May 2005
Posts: 39
 

Default

Thanks that is helping me understand things but no it didnt work for me.

Every product has a category - All I need is the variable for the all of its subcats and I'll be away! I can't seem to find it.
__________________
Version 4.0.14
Reply With Quote
  #4  
Old 07-26-2005, 08:36 AM
 
sermad sermad is offline
 

Advanced Member
  
Join Date: May 2005
Posts: 39
 

Default

Firgured this out myself. Damn Im on a roll today!

Create a new page called 'sub_cat_fields_array.php' in modules/Sub_Cats

Code:
<?php if ( !defined('XCART_SESSION_START') ) { header("Location: ../../"); die("Access denied"); } if($products) { foreach($products as $product) { $productid = $product['productid']; $sub_cats[$productid] = func_query("SELECT $sql_tbl[products_categories].* FROM $sql_tbl[products_categories] WHERE ($sql_tbl[products_categories].productid = '$productid') AND $sql_tbl[products_categories].main='N'"); } } $smarty->assign("sub_cats",$sub_cats); ?>

Then include the file in products.php

Code:
include $xcart_dir."/modules/Sub_Cats/sub_cat_fields_array.php";

Then in your products.tpl you can view the items subcats.

Code:
{assign var="subtcat" value=$sub_cats[$pid][0].categoryid}

This is for a product with one subcat. If your product has more then you need to loop through this.
__________________
Version 4.0.14
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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:12 AM.

   

 
X-Cart forums © 2001-2020