X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Showing a products subcat on the products page (https://forum.x-cart.com/showthread.php?t=15431)

sermad 07-25-2005 07:21 AM

Showing a products subcat on the products page
 
Hi guys.

How can I show the subcategory of a product on the products page?

Dongan 07-25-2005 06:34 PM

Hi,

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

http://forum.x-cart.com/viewtopic.php?t=5131

sermad 07-26-2005 03:00 AM

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.

sermad 07-26-2005 08:36 AM

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.


All times are GMT -8. The time now is 09:24 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.