ReactionCode Posted November 5, 2014 Share Posted November 5, 2014 Hi I'm trying to do a module and when I located on category page I need to load the products array in header. Because the smarty limitations It's not possible to call the var $products on header.tpl. I need the next data to work on my script $product.id, $product.name, $product.price how can i get the var on the header hook? I tried this but don't work module.php public function hookHeader($params) { if ($page_name == 'category'){ $products = new Products($_GET['products']); $smarty->assign('products', $products); } return $this->display(__FILE__, 'views/templates/hook/header.tpl'); } header.tpl {if $page_name == 'category'} {foreach from=$products item=product} my-code {$product.id|escape:'htmlall':'UTF-8'}; my-code {$product.name|escape:'htmlall':'UTF-8'}; {/foreach} {/if} Thanks Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted November 5, 2014 Share Posted November 5, 2014 Hey man, Probably you can do that. What is the error you got? Link to comment Share on other sites More sharing options...
ReactionCode Posted November 5, 2014 Author Share Posted November 5, 2014 Hi Tung The problem is that I need the variable $products that loads when you are in a category or manufacturer available in the header hook how can I do that? thanks. Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted November 6, 2014 Share Posted November 6, 2014 Hello, I'm sorry but I can not imagine what's happening to you, so I can not help here. Link to comment Share on other sites More sharing options...
ReactionCode Posted November 6, 2014 Author Share Posted November 6, 2014 Tung, can you confirm me if the sintaxis for get the products var is ok? Best regards. Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted November 7, 2014 Share Posted November 7, 2014 If you product item is an array, you can access its attributes using: $product.id If it's an object, you should use: $product->id Hope this helps! Link to comment Share on other sites More sharing options...
albertfajarito Posted November 7, 2014 Share Posted November 7, 2014 will this line of code return a database query result? new Products($_GET['products']) unless your 100% sure that it will $product.id I don't think calling it the usual way will work. Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted November 12, 2014 Share Posted November 12, 2014 The best way is to attache your module here. I can not imagine how your code looks like and can not give you a helping hand. 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