Jump to content

Recommended Posts

Hi guys,

 

Bit of a newbie, but I've searched high and low and cannot get the category name of the product to show up on product.tpl!

 

I've tried 

 

<h1>{$category->name}</h1>

 

No to avail. Any tips? Thanks!

K

Share this post


Link to post
Share on other sites

So since nobody knows, or is not sharing, I managed to hack product.php and added

 

		$result = Db::getInstance()->ExecuteS('

	SELECT `id_category` FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.intval($_GET['id_product']).'');


	$smarty->assign('current_category_id',$result);

	$result_catname = Db::getInstance()->ExecuteS('

	SELECT `name` FROM `'._DB_PREFIX_.'category_lang` WHERE `id_category` = '.intval($result[0]['id_category']).'');


	$smarty->assign('current_category',$result_catname);

 

 

And on product.tpl, {$current_category[0].name} will show the category name of the current product.

 

Hopefully this helps someone out there...

 

Ciao

 

 

Share this post


Link to post
Share on other sites

Hi,
I use this in product.tpl on RC3 :

{if $category}
   {$category->name}
{elseif $product->id_category_default != 1}
   {php}
       global $product, $cookie;
       $this->assign('default_category', new Category($product->id_category_default, $cookie->id_lang));
   {/php}
   {$default_category->name}
{else}
   {$shop_name}
{/if}



it's bad to use php in template file but I think it's better than hack product.php

Regards

Share this post


Link to post
Share on other sites
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More