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)
-   -   Put Category Name in products.tpl (https://forum.x-cart.com/showthread.php?t=39848)

matthewstroh 05-17-2008 07:49 AM

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.

Yurij 05-19-2008 01:44 AM

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.

matthewstroh 05-19-2008 09:16 AM

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.

TheWrongGrape 07-14-2008 04:21 PM

Re: Put Category Name in products.tpl
 
Was this ever solved? This is something I am interested in also.

matthewstroh 07-14-2008 05:19 PM

Re: Put Category Name in products.tpl
 
No, it has yet to be solved.

c.vogels 02-16-2009 04:35 AM

Re: Put Category Name in products.tpl
 
I am also interested in the solution of this issue...

Jon 02-16-2009 09:33 AM

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.

clik 04-13-2009 07:43 PM

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... :oops: something like
category.main eq "Y" and display the product's main category.

Thank you in advance ;)

I'm working with xcart 4.2.


All times are GMT -8. The time now is 12:05 PM.

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