Jump to content

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!

Edited by hideaki (see edit history)
Link to comment
Share on other sites

i think what you did should work, but you should be putting that code in the ProductController.php, in the preprocess function

 

the first thing i noticed is that you create a variable $lastVisitedCat to hold the Category object, but in the second line you refer to it as $category. try making them match and see if things change.

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