rayrayrugby Posted October 20, 2014 Share Posted October 20, 2014 Hi, I'm new on prestashop, I'm currently developing a custom module for back office in wich I need to force the call of the Hook 'displayBackofficeHeader' repeatedly, but I don't know how I can do this. Could somebody help me please ? Link to comment Share on other sites More sharing options...
cristic Posted October 20, 2014 Share Posted October 20, 2014 To call a hook inside a module, you can use: Hook::exec('displayBackOfficeHeader', array()) To call it in a tpl file, you should first assign it to a smarty variable: $this->context->smarty->assign('displayBackOfficeHeader', Hook::exec('displayBackOfficeHeader', array())); But you should be careful with this, because for example if you have javascript code - it will be added twice. 1 Link to comment Share on other sites More sharing options...
rayrayrugby Posted October 20, 2014 Author Share Posted October 20, 2014 Thanks for your reply cristic, Hook::exec('displayBackOfficeHeader', array()) if I try this method, will all the transplanted module of the hook run ? thanks. Link to comment Share on other sites More sharing options...
cristic Posted October 20, 2014 Share Posted October 20, 2014 Yes. And in the same order. 1 Link to comment Share on other sites More sharing options...
rayrayrugby Posted October 20, 2014 Author Share Posted October 20, 2014 Thanks cristic, I'm gonna try this . Link to comment Share on other sites More sharing options...
rayrayrugby Posted October 20, 2014 Author Share Posted October 20, 2014 (edited) it seems to work except for the .tpl of my module, wich should be displayed when the hook backofficefooter is executing. Maybe because I don't use this method ? : (And sorry the Hook is "displaybackofficefooter") $this->context->smarty->assign('displayBackOfficeFooter', Hook::exec('displayBackOfficeFooter', array())); Edited October 20, 2014 by rayrayrugby (see edit history) Link to comment Share on other sites More sharing options...
rayrayrugby Posted October 21, 2014 Author Share Posted October 21, 2014 To be more exact, for the moment what I want is display on backoffice pages a simple js alert that I've created inside of a tpl file. So to do this i used the hooks "actionvalidateorder" and "displaybackofficefooter" like that : public function hookactionValidateOrder($params) { Hook::exec('displayBackOfficeFooter', array()); } public function hookdisplayBackOfficeFooter($params) { return $this->display(__FILE__, 'test.tpl'); } But when I make an order nothing happens, I really don't know why.. Link to comment Share on other sites More sharing options...
cristic Posted October 21, 2014 Share Posted October 21, 2014 I am not sure I completely understand what you are trying to accomplish. I believe you want a javascript code to execute in BO when an order is placed in FO. If so, then this is not the correct approach. Connect your module only to hookdisplayBackOfficeFooter and here display your tpl contents but also put the javascript code inside, which will constantly check, using AJAX calls, if an order has been placed. If you use hookactionValidateOrder, then the content is executed on the order validation, but in the same call/session where the order was placed. So this will not help you. 1 Link to comment Share on other sites More sharing options...
rayrayrugby Posted October 21, 2014 Author Share Posted October 21, 2014 That's exactly what I want to do cristic Link to comment Share on other sites More sharing options...
rayrayrugby Posted October 22, 2014 Author Share Posted October 22, 2014 (edited) Connect your module only to hookdisplayBackOfficeFooter and here display your tpl contents but also put the javascript code inside, which will constantly check, using AJAX calls, if an order has been placed. Should I in this case used the AJAX calls in the hookactionValidateOrder, to make sure the calls are made if orders has been placed ? Edited October 22, 2014 by rayrayrugby (see edit history) 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