Jump to content

Get the category name?


Recommended Posts

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

 

 

Link to comment
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

Link to comment
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...