Jump to content

Get current category id on product page


Alldo Group

Recommended Posts

I'm trying to fetch the current id_category on the product page.

I have searched the forums but with no results.

 

I need to display a notice for some categories.

 

This is what I am trying to use in product.tpl, with no success.

 

{php}
if( $smarty.get.id_category == '5' OR $product->id_category_default == '5'){
echo 'Test';
}
{/php}

 

Using PS 1.4.4

php_tag=true;

 

Performance settings:


  •  
  • force compile
  • cache disabled

 

Thanks in advance

Link to comment
Share on other sites

Thanks for your reply!

 

Still can't get it to work.

 

There are sub-categories. The first is 5 and the second are, for example 15.

The easiest way would be to check the first category id.

 

Im not sure how to achive this, is this correct:

 

$prodId = $product->id_category_default;

if( $prodId == 5){
   echo 'An important notice!';
}

 

Thanks!

Link to comment
Share on other sites

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...