View Single Post
  #2  
Old 11-16-2011, 04:56 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Parent Category ID on Search Page (products_t.tpl)

Search results can contain products from different categories...

You can try creating a Smarty modifier for the purpose and further use it like this: {$product.productid|get_parent_category} in the templates.

To create a new Smarty modifier plugin create the "include/templater/plugins/modifier.get_product_parent_category.php" script with the following content:

PHP Code:
<?php 

if (!defined('XCART_START')) { header("Location: ../../../"); die("Access denied"); } 

function 
smarty_modifier_get_product_parent_category($productid) {
        global 
$sql_tbl;

        
// main product category id
        
return func_query_first_cell("SELECT categoryid FROM $sql_tbl[products_categories] WHERE main='Y' AND productid='$productid'");


?>
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote