![]() |
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. |
Re: Put Category Name in products.tpl
Quote:
If you look at the current category, all products will have the same name category. PHP Code:
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. |
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. |
Re: Put Category Name in products.tpl
Was this ever solved? This is something I am interested in also.
|
Re: Put Category Name in products.tpl
No, it has yet to be solved.
|
Re: Put Category Name in products.tpl
I am also interested in the solution of this issue...
|
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 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. |
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.