Crezzur.com Posted July 22, 2016 Share Posted July 22, 2016 (edited) Hello, I have created a module which alters the view of the product page. How it works:1. I re-assign the $features variable with different values for a custom display. 2. in call the variable ($features) in mymodule\views\templates\hook\page.tpl 3. it displays everything correctly. Now i have added a tabbed view style to this module, so in to work smoothly i have added this to page.tpl <!-- More info --> {if isset($product) && $product->description} <div id="idTab1"> {html_entity_decode($product->description|escape:'html':'UTF-8')} </div> {/if} <!--end More info --> But for some reason the variable $product has no data in it. It works on the product page, but my page.tpl file does not load the data. So i will need to call the $product variable in my module and assign it to my .tpl file, but how do you call a variable which is not created in your module? Which result in only show my "features" tab and not the "product comment" tab Any idea on how to load the variables in my page.tpl file so the work? Kind regards! Edited July 22, 2016 by Crezzur (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted July 24, 2016 Share Posted July 24, 2016 You can't access Smarty variables from one template in another template unless you pass them through one template to another. I suggest that you pass the $product variable into your page.tpl template like this: if ((int)Tools::getValue('id_product')) { $product = new Product((int)Tools::getValue('id_product'), true, $this->context->language->id, $this->context->shop->id); $this->context->smarty->assign('product', $product); } 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