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

Put Category Name in products.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-17-2008, 07:49 AM
  matthewstroh's Avatar 
matthewstroh matthewstroh is offline
 

Member
  
Join Date: Oct 2007
Location: Portland, OR.
Posts: 16
 

Question Put Category Name in products.tpl

How would I call the product's category name in the products.tpl file? I'd like to have the title of the product just above a line that says the category name. Like this...

3 Button Red T-Shirt
From: JC Penny

Black Felt Fedora
From: Macy's

I don't know enough about how X-cart's individual pages make certain elements available for use. For example, on certain pages (like categories.tpl) you can use $c.category to display a category name, but that won't work here. Nor will $category, though $cat will display the number of the category, but that's not what I'm going for.
__________________
Matthew Stroh
Version 4.1.9
Reply With Quote
  #2  
Old 05-19-2008, 01:44 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: Put Category Name in products.tpl

Quote:
Originally Posted by matthewstroh
How would I call the product's category name in the products.tpl file? I'd like to have the title of the product just above a line that says the category name. Like this...

3 Button Red T-Shirt
From: JC Penny

Black Felt Fedora
From: Macy's

I don't know enough about how X-cart's individual pages make certain elements available for use. For example, on certain pages (like categories.tpl) you can use $c.category to display a category name, but that won't work here. Nor will $category, though $cat will display the number of the category, but that's not what I'm going for.

If you look at the current category, all products will have the same name category.

PHP Code:
.........
From: {$current_category.category}
........ 

But it will not work for blocks: "Featured products" and "Search".
For them, this problem is solved difficult. Will write later how to solve it, if you need it.
Reply With Quote
  #3  
Old 05-19-2008, 09:16 AM
  matthewstroh's Avatar 
matthewstroh matthewstroh is offline
 

Member
  
Join Date: Oct 2007
Location: Portland, OR.
Posts: 16
 

Default Re: Put Category Name in products.tpl

How is it possible that the block knows to display so much information about the product except which category it belongs to? If you have the solution to this, I'd gladly appreciate it because you're right, it only displays on the product's current category page which makes them all display the same name.

Also, the place where this is most important is the homepage: but, like you said, it doesn't work in blocks so nothing appears on the featured product block on the home page.

Any ideas? I'd gladly appreciate some help with this.
__________________
Matthew Stroh
Version 4.1.9
Reply With Quote
  #4  
Old 07-14-2008, 04:21 PM
 
TheWrongGrape TheWrongGrape is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: Los Angeles, CA
Posts: 68
 

Default Re: Put Category Name in products.tpl

Was this ever solved? This is something I am interested in also.
Reply With Quote
  #5  
Old 07-14-2008, 05:19 PM
  matthewstroh's Avatar 
matthewstroh matthewstroh is offline
 

Member
  
Join Date: Oct 2007
Location: Portland, OR.
Posts: 16
 

Default Re: Put Category Name in products.tpl

No, it has yet to be solved.
__________________
Matthew Stroh
Version 4.1.9
Reply With Quote
  #6  
Old 02-16-2009, 04:35 AM
 
c.vogels c.vogels is offline
 

Member
  
Join Date: Sep 2006
Posts: 18
 

Default Re: Put Category Name in products.tpl

I am also interested in the solution of this issue...
__________________
x-cart 4.1.10 gold
Reply With Quote
  #7  
Old 02-16-2009, 09:33 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Put Category Name in products.tpl

Try this (tested on 4.2):

Open include/search.php.

FIND:

Code:
$fields[] = "$sql_tbl[products].*";

AFTER ADD:

Code:
// WCM - Query Category $fields[] = "$sql_tbl[categories].category"; // / WCM - Query Category

Open
4.1: skin1/customer/main/products.tpl and/or skin1/customer/main/products_t.tpl
4.2: skin1/customer/main/products_list.tpl and/or skin1/customer/main/products_t.tpl

FIND (this will differ slightly on 4.1.x as it will specify a product.php url with a different class. Basically put the new code where you want the category to be displayed.):

Code:
<a href="{$url}" class="product-title">{$product.product|escape}</a>

Code:
{if $product.category ne ""}<br />{$lng.lbl_category}: {$product.category}{/if}

Also make sure the 'lbl_category' language variable exists.
Reply With Quote
  #8  
Old 04-13-2009, 07:43 PM
  clik's Avatar 
clik clik is offline
 

Advanced Member
  
Join Date: Mar 2006
Location: Canada
Posts: 30
 

Question Re: Put Category Name in products.tpl

Hi,
I was just looking for similar code. It works except I need to display the MAIN category specified for individual product. I'm not a MySQL expert... something like
category.main eq "Y" and display the product's main category.

Thank you in advance

I'm working with xcart 4.2.
__________________
__________________
XC5: 5.3.4.4
PHP: 7.0.26
MySQL server: 5.5.56-MariaDB
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 12:12 PM.

   

 
X-Cart forums © 2001-2020