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

Parent Category ID on Search Page (products_t.tpl)

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-09-2011, 07:27 AM
 
jvolvovski jvolvovski is offline
 

Advanced Member
  
Join Date: Nov 2007
Posts: 46
 

Default 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
__________________
Version 4.3.2
Reply With Quote
  #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

The following user thanks qualiteam for this useful post:
gb2world (11-16-2011)
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 12:53 AM.

   

 
X-Cart forums © 2001-2020