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)
-   -   Parent Category ID on Search Page (products_t.tpl) (https://forum.x-cart.com/showthread.php?t=61541)

jvolvovski 11-09-2011 07:27 AM

Parent Category ID on Search Page (products_t.tpl)
 
Hi,
I'm trying to retrieve a parent category id for products on the search results page.
There doesn't seem to be any variables that refer to a category name/id/etc.

Is there a way for me to create a new variable?

I'm using this for the category pages:
{if $current_category.parentid eq 249 || $cat eq 249}{else}{/if}
and would want to recreate this same structure on the search page.

Thanks!
Jenny

qualiteam 11-16-2011 04:56 AM

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'");


?>



All times are GMT -8. The time now is 02:50 AM.

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