qrczak Posted January 21, 2017 Share Posted January 21, 2017 Presta 1.6, my test module is installed and assign to displayHeader in BO I know how to assign variable to hook but now I want to assign variable to my template /modules/myModule/views/templates/front/myView.tpl inside myView.tpl is: {$myVariable} and now I want into Header hook display my view where I can use {$myVariable} this give my only opportunity display {$myVariable} into general header.tpl: public function hookHeader() { $this->context->smarty->assign(array( 'myVariable' => 'myText' )); } but how assign my variable to my template and display it through {$HOOK_HEADER} in header.tpl? Link to comment Share on other sites More sharing options...
razaro Posted January 21, 2017 Share Posted January 21, 2017 Check documentation first http://doc.prestashop.com/display/PS16/Displaying+content+on+the+front+office it is part of "Creating a module" documentation. But one thing to mention, hookheader is for linking css and js files. To display something you should use hookTop or maybe hooDisplayNav. Best way to learn is to check existing code, so search for similar ideas in nativemodules like https://github.com/PrestaShop/blockuserinfo/blob/master/blockuserinfo.php public function hookDisplayTop($params) { if (!$this->active) return; $this->smarty->assign(array( 'cart' => $this->context->cart, 'cart_qties' => $this->context->cart->nbProducts(), 'logged' => $this->context->customer->isLogged(), 'customerName' => ($this->context->customer->logged ? $this->context->customer->firstname.' '.$this->context->customer->lastname : false), 'firstName' => ($this->context->customer->logged ? $this->context->customer->firstname : false), 'lastName' => ($this->context->customer->logged ? $this->context->customer->lastname : false), 'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order' )); return $this->display(__FILE__, 'blockuserinfo.tpl'); } Link to comment Share on other sites More sharing options...
qrczak Posted January 22, 2017 Author Share Posted January 22, 2017 First of all thank you for your answer. Very helpful for me. 1. I was reading documentation but I had to miss this one 2. one thing - you said: "But one thing to mention, hookheader is for linking css and js files." you right but if I want to add something to HEAD section for example additional meta tags I can use hookDisplayHeader and my template will rendered in HEAD section. Any way Thank you once again 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