Jump to content

Custom Code


hideaki

Recommended Posts

Hi guys,

 

I'm curious about the relationship between PHP and TPL files used in PrestaShop. Today I decided I needed to do some coding to get custom information passed to the product.tpl. So I went to the product.php and added my custom code there (product.php)

 

$lastVisitedCat = new Category(intval($cookie->last_visited_category), intval($cookie->id_lang));
$lastVisitedCatName = $category->name;
$smarty->assign('lastVisitedCatName', $lastVisitedCatName);

 

However, when I tried using {lastVisitedCatName} on product.tpl, the information is not shown. I doubt there is anything wrong with the code as when I tried the example on Smarty's site. it doesn't work as well:

 

$smarty->assign('Name', 'Fred');

 

I have a sense that it's something to do with controllers. But how do I go about in that approach? Hope to hear suggestions and feedbacks. Thanks!

Link to comment
Share on other sites

  • 2 weeks 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...