junkypic Posted April 14, 2020 Share Posted April 14, 2020 (edited) I'm using Prestashop 1.7.6.4 to develop a payment module. I want to render a template in a hook. I'm doing that via the following code: class MyModuleName extends PaymentModule { public function hookActionValidateOrder($params) { /** * Verify if this module is enabled */ if (!$this->active) { return; } if (Configuration::get('inline')) { $this->context->smarty->assign([ 'module' => $order->module ]); return $this->display(__FILE__, 'views/templates/hook/displayStatusOrder.tpl'); } // more code goes here } } Do note that I've also tried with return $this->fetch('module:myModule/views/templates/hook/displayStatusOrder.tpl'); results are the same. However I'm getting the following error: (1/1) SmartyException 0():Missing '$template' parameter in smarty_internal_templatebase.php line 177 at Smarty_Internal_TemplateBase->_execute(null, null, 'layouts/layout-full-width.tpl', null, 0) in smarty_internal_templatebase.php line 116 at Smarty_Internal_TemplateBase->fetch(null, null, 'layouts/layout-full-width.tpl', null, false, true, false) in SmartyDev.php line 40 at SmartyDev->fetch(null, null, 'layouts/layout-full-width.tpl') in FrontController.php line 683 at FrontControllerCore->smartyOutputContent(null) in FrontController.php line 667 at FrontControllerCore->display() in Controller.php line 312 at ControllerCore->run() in Dispatcher.php line 515 at DispatcherCore->dispatch() in index.php line 74 I'm absolutely sure that my template exists. And it has the correct name. The template contains the following code: {if $module == "myModule"} <script> $(document).ready(function() { alert('test'); }); alert('test'); </script> {/if} My folder structure is like so: myModuleName views templates hook displayStatusOrder.tpl I think it's because I'm trying to render it in this specific hook. It seems that for other hooks rendering templates works just fine. I've tried deleting the cache, reinstalling the module, etc etc. I'm clearly missing something obvious. Any help is appreciated. Edited April 14, 2020 by junkypic (see edit history) Link to comment Share on other sites More sharing options...
idnovate.com Posted April 15, 2020 Share Posted April 15, 2020 hookActionValidateOrder is an action hook, not a display hook, so you can not display a template. You need to check in your template where you want to display your code which hooks are available. 1 Link to comment Share on other sites More sharing options...
junkypic Posted April 15, 2020 Author Share Posted April 15, 2020 1 hour ago, idnovate.com said: hookActionValidateOrder is an action hook, not a display hook, so you can not display a template. You need to check in your template where you want to display your code which hooks are available. Indeed that was the problem. For my case specifically I had to reroute to a controller and display a tpl with some javascript in it. 1 Link to comment Share on other sites More sharing options...
Flakkak Posted March 2, 2021 Share Posted March 2, 2021 Hi, How did you solve this error. I am having the same issue over here after installing a module to change template colors. Prestashop 1.7.7.2 Link to comment Share on other sites More sharing options...
idnovate.com Posted May 27, 2022 Share Posted May 27, 2022 On 3/2/2021 at 8:02 PM, Flakkak said: Hi, How did you solve this error. I am having the same issue over here after installing a module to change template colors. Prestashop 1.7.7.2 Why don't you ask it directly to the module developer? 😇 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