hideaki Posted May 23, 2012 Share Posted May 23, 2012 (edited) 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 May 23, 2012 by hideaki (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted May 24, 2012 Share Posted May 24, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now