Tomas Contos Posted May 2, 2019 Share Posted May 2, 2019 Hi, I have custom hook which I add to product-list.tpl. It is added to container <div class="product-image-container"> {hook h="displayTagsInProductImageInProductLists" product=$product} I have registered module to this hook /checked in back office module positions/ In tpl I can access variable $product which is record from variable $products defined by default in {foreach from=$products item=product name=products} in the same file above my code I have created function in module which should display template public function hookDisplayTagsInProductImageInProductLists($params) { return $this->display(__FILE__, 'hookDisplayTags.tpl'); } I have no access to variable $product in template hookDisplayTags Code in template is <p>{$product|var_dump}</p> I am getting NULL If I move code from template straight into tpl I can access variable $product to make it work but I need to know if there is any way to access tpl variables inside custom hook. If you have any link or explanation I will appreciate it. Thank you for your help. Link to comment Share on other sites More sharing options...
Daresh Posted May 2, 2019 Share Posted May 2, 2019 You need to pass it to smarty. $this->smarty->assign('product', $params['product']); 2 Link to comment Share on other sites More sharing options...
Tomas Contos Posted May 2, 2019 Author Share Posted May 2, 2019 27 minutes ago, Daresh said: You need to pass it to smarty. $this->smarty->assign('product', $params['product']); Thank you sir / Dzienky panu It is working now. You saved my day. 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