You are here:  » Include Category link on Products Page

Support Forum



Include Category link on Products Page

Submitted by Paulzie on Wed, 2007-12-26 22:28 in

If I view a certian product, I'd like to include a link to that products category.

So if I view a "XYZ Can Opener", there would be a link that takes me to /category/Can-Openers/

I presume I need to edit html/product.php but nothing I've tried has worked.

Any pointers?

Submitted by support on Fri, 2007-12-28 13:28

Hi,

Within html/product.php, the category of the product (if one exists) is in the following variable:

$mainProduct["category"]

Therefore, you could create a link as required with the following code (just paste this straight into html/product.php:

<?php
  
if ($mainProduct["category"])
  {
    
$href $config_baseHREF."category/".tapestry_hyphenate($mainProduct["category"])."/";
    print 
"More products in <a href='".$href."'>".$mainProduct["category"]."</a>";
  }
?>

That should do the trick!

Cheers,
David.

Submitted by Paulzie on Sat, 2007-12-29 20:26

Cheers David - looks good. Not sure where I went wrong with my code.

One thing it has shown up is the vast differences in which category different retailers give various items.