Fabien Serny Posted January 28, 2012 Share Posted January 28, 2012 Hi all, Where do you think we should add hooks in 1.5 ? Don't forget to describe why you need the new hook for NB : I'll read all your answers but I can't promise that all hooks will be added. Link to comment Share on other sites More sharing options...
Fabien Serny Posted January 28, 2012 Author Share Posted January 28, 2012 Hooks have already been added in ObjectModel, AdminController and on AdminProducts Link to comment Share on other sites More sharing options...
Yann - Prestaplugins Posted January 28, 2012 Share Posted January 28, 2012 Hi Fabien, I would love 4 new hooks : - when you enter the shipping number in the order page (AdminOrders.php => process) - when you send the mail with the new password on password recovery (PasswordControllerCore.php => process) - when a customer send a message using the contact form (ContactFormControllerCore.php => preProcess) - in the mailalert module, when a product is available again, and you send the email to customer (mailalert.php => sendCustomerAlert) I need all of them because i send all these information by SMS with my sendsms module. But i'm sure it can be usefull for someone else Link to comment Share on other sites More sharing options...
justweb Posted January 28, 2012 Share Posted January 28, 2012 Hello, Add a hook for hotizontal nav. Currently in the new theme, one div is open in header.tpl and close in blocktopmenu.tpl (module).(cf http://forge.prestashop.com/browse/PSFV-399) Hook Admincategory for adding a tab in the page add category 1 Link to comment Share on other sites More sharing options...
Fabien Serny Posted January 28, 2012 Author Share Posted January 28, 2012 Hi Patanock, Yours hooks seems ok to me except the one of recovery password. I will talk about it with the team and come back to you. Hi Kalyrock, I'm okay for the hook in AdminCategory. Do you want me to fix the bug reported on the forge or do you mean you want me to add a hook in the blocktopmenu.tpl ? Link to comment Share on other sites More sharing options...
Raphaël Malié Posted January 28, 2012 Share Posted January 28, 2012 I want a hook to remove Smarty Fabien ! 1 Link to comment Share on other sites More sharing options...
justweb Posted January 28, 2012 Share Posted January 28, 2012 Hi Patanock, Yours hooks seems ok to me except the one of recovery password. I will talk about it with the team and come back to you. Hi Kalyrock, I'm okay for the hook in AdminCategory. Do you want me to fix the bug reported on the forge or do you mean you want me to add a hook in the blocktopmenu.tpl ? Hi, Just add a hook horizontal nav and change the html in blockmenu.tpl. This will fix the bug. thx Link to comment Share on other sites More sharing options...
Fabien Serny Posted January 28, 2012 Author Share Posted January 28, 2012 Hi Raphael, Please fix the bug reported by kalyrock.com http://forge.prestashop.com/browse/PSFV-399 which is assigned to you and take care of your rabbit =) Hi Kalyrock, Raphael will take care of the bug but adding a hook in a module, I'm not sure I see the interest :X Hooks permits develop to add / change functionalities without editing core file. Here you can duplicate the module, give a new name to it, and change its functionnement. Or did I miss something ? Link to comment Share on other sites More sharing options...
justweb Posted January 28, 2012 Share Posted January 28, 2012 Hi Raphael, Please fix the bug reported by kalyrock.com http://forge.prestas...browse/PSFV-399 which is assigned to you and take care of your rabbit =) Hi Kalyrock, Raphael will take care of the bug but adding a hook in a module, I'm not sure I see the interest :X Hooks permits develop to add / change functionalities without editing core file. Here you can duplicate the module, give a new name to it, and change its functionnement. Or did I miss something ? Currently, there is just one hook in the header of the page (not in the module): hook top. It ll be usefull to have a second hook (ex : nav horizontal). Link to comment Share on other sites More sharing options...
Raphaël Malié Posted January 28, 2012 Share Posted January 28, 2012 Kalyrock : I will take care of this new hook, and I will fix the problem in blockmenu too Link to comment Share on other sites More sharing options...
prestamax Posted January 31, 2012 Share Posted January 31, 2012 it would be great if there will be some basic documentation about available hooks in prestashop 1.5. Link to comment Share on other sites More sharing options...
phrasespot Posted January 31, 2012 Share Posted January 31, 2012 A hook in the overriden update method of Customer class: postCustomerUpdate never mind, I see you've already solved the problem at its root in ObjectModel Link to comment Share on other sites More sharing options...
Samy_R Posted February 1, 2012 Share Posted February 1, 2012 It should be useful to add hooks on AdminImportController : - to add extra fields to available fields - to be able to process these new fields on .csv computing It should simplify import of fields with extra information Link to comment Share on other sites More sharing options...
justweb Posted February 2, 2012 Share Posted February 2, 2012 Hook for category page : to be able to add extra fields in the bottom of category admin page. ex: displayAdminCategoryExtra Link to comment Share on other sites More sharing options...
Fabien Serny Posted February 2, 2012 Author Share Posted February 2, 2012 Hi, I added new hooks, amongst it, there were some hooks you asked for : - actionAdminOrdersTrackingNumberUpdate - actionPasswordRenew - actionModuleMailAlertSendCustomer - displayAdminCategoriesForm I just commited them, I'll let you test @Patanock I'm not sure for this one "when a customer send a message using the contact form (ContactFormControllerCore.php => preProcess)", I think you meant ContactController.php, where in the code do you need a hook ? @Phrasespot "A hook in the overriden update method of Customer class: postCustomerUpdate" Why ? This method call parent::update and there already are hooks in ObjectModel before and after update. @PrestaMax, do not worry, I will make one ! Link to comment Share on other sites More sharing options...
phrasespot Posted February 2, 2012 Share Posted February 2, 2012 @Phrasespot"A hook in the overriden update method of Customer class: postCustomerUpdate" Why ? This method call parent::update and there already are hooks in ObjectModel before and after update. Yep, I noticed and modified the post but obviously you caught it before the modification Link to comment Share on other sites More sharing options...
Samy_R Posted February 3, 2012 Share Posted February 3, 2012 As there is no CRON system in Prestashop, it should be very useful to create one and add hooks to let modules plug on it Link to comment Share on other sites More sharing options...
prestamax Posted February 4, 2012 Share Posted February 4, 2012 Hello, Add a hook for hotizontal nav. Currently in the new theme, one div is open in header.tpl and close in blocktopmenu.tpl (module).(cf http://forge.prestas...browse/PSFV-399) Hook Admincategory for adding a tab in the page add category I would second this. If the top nav had it's own hook there would be more styling options. Currently you are dependent on the closing div in the top nav module to place it outside of the header right area. No chance to put the horizontal nav in a separate container (for example if you want to extend the navbar across the entire width of the screen). This would require modification of the top nav module. If the top nav had it's own hook this won't be a problem at all. The horizontal nav simply doesn't belong in the top right header area where the current hook is placed. A navigation usually needs a full page width and putting any closing divs in the top nav module in order to get it placed correctly is not very satisfying. Link to comment Share on other sites More sharing options...
Mark Hesketh Posted February 6, 2012 Share Posted February 6, 2012 Will there be a hook or similar to be able to add custom customer registration fields to the checkout process, as well as remove them? I realise this is possible at the moment but it's tricky. Really the only fields that I'd think are required by the system would be username/password (digital download only stores)? Thanks, Mark Link to comment Share on other sites More sharing options...
Pixeles Posted February 6, 2012 Share Posted February 6, 2012 Hi Fabian, Great idea for the hooks, can't wait. Could you please list all new hooks so we don't ask you twice ? Thanks Link to comment Share on other sites More sharing options...
phrasespot Posted March 12, 2012 Share Posted March 12, 2012 Where do you think we should add hooks in 1.5 ? One for maintenance page output please Link to comment Share on other sites More sharing options...
Dev On Web Posted March 12, 2012 Share Posted March 12, 2012 Add hook in a module is possible? Link to comment Share on other sites More sharing options...
Mark Hesketh Posted March 15, 2012 Share Posted March 15, 2012 Any update on if any of these suggestions will be possible? I welcome them all. Link to comment Share on other sites More sharing options...
Fabien Serny Posted March 16, 2012 Author Share Posted March 16, 2012 Hi Mark, A hook in registration form will not permit you to remove fields, only add some. I will add a hook for this. Hi Ivoire, Yes, you can add a hook in a module. I will document this part. Hi Phrasespot, I will add one. Hi Pixeles, I added many many hooks, all describing here will be very long. I'll make a documentation about it. Best regards, Link to comment Share on other sites More sharing options...
phrasespot Posted March 16, 2012 Share Posted March 16, 2012 Hi Phrasespot,I will add one. Great, thanks! Link to comment Share on other sites More sharing options...
Mark Hesketh Posted March 17, 2012 Share Posted March 17, 2012 Hi Mark, A hook in registration form will not permit you to remove fields, only add some. I will add a hook for this. Hi Ivoire, Yes, you can add a hook in a module. I will document this part. Hi Phrasespot, I will add one. Hi Pixeles, I added many many hooks, all describing here will be very long. I'll make a documentation about it. Best regards, Brilliant, thanks Fabien Link to comment Share on other sites More sharing options...
jacky75 Posted March 20, 2012 Share Posted March 20, 2012 Hi, it could be very useful an hook related with the end of a new order status assignment. Currently there are two hooks in this area but they're not able to be related with the new order status (the first hook is raised before the status is changed, the second one during the order status updates). Currently, using these hooks it's not possible to analyze the "new status" and if necessary to assign a new one because after the hook execution the OrderHistory is updated with the "old" order history status. Think in this way. If the new order status is "AAA" then, after some checks, I would like to move the order to the status BBB. At the end, currently the last order status will still be AAA and not my BBB properly added to order history using the API. Regards, Link to comment Share on other sites More sharing options...
absolutic Posted March 21, 2012 Share Posted March 21, 2012 Hi Ivoire, Yes, you can add a hook in a module. I will document this part. It would be great if you could say in a nutshell until the documentation is ready, is it possible to add our own hooks from modules in any other way than copying files in the Override folder? Link to comment Share on other sites More sharing options...
mexique1 Posted March 21, 2012 Share Posted March 21, 2012 To add a hook in a module, just use the Hook ObjectModel to save it in database. What is complicated ? Link to comment Share on other sites More sharing options...
absolutic Posted March 21, 2012 Share Posted March 21, 2012 To add a hook in a module, just use the Hook ObjectModel to save it in database. What is complicated ? I want to add hooks to the existent Prestashop classes and controllers from my module and my question is if there is possible way to do it without copying files to override folder. Link to comment Share on other sites More sharing options...
phrasespot Posted March 21, 2012 Share Posted March 21, 2012 To add a hook in a module, just use the Hook ObjectModel to save it in database. What is complicated ? It is not complicated but Hook class does not expose any of its fields like other subclasses of ObjctModel so you cannot do something like: $h = new Hook(); $h->name = '...'; $h->title = '..'; $h->description = '...'; ... $h->save(); One has to operate on DB directly to add a hook (with all the fields populated). Link to comment Share on other sites More sharing options...
mexique1 Posted March 21, 2012 Share Posted March 21, 2012 Ho really ? Link to comment Share on other sites More sharing options...
phrasespot Posted March 21, 2012 Share Posted March 21, 2012 Ho really ? yep, INSERT INTO PREFIX_hook... :/ Link to comment Share on other sites More sharing options...
Dev On Web Posted March 22, 2012 Share Posted March 22, 2012 yep, INSERT INTO PREFIX_hook... :/ I agree with that ! Link to comment Share on other sites More sharing options...
mexique1 Posted March 22, 2012 Share Posted March 22, 2012 Can't we do that ? Module :: getInstanceByName('someModule')->registerHook('someHook'); But in any case it's not what absolutic wants Link to comment Share on other sites More sharing options...
phrasespot Posted March 22, 2012 Share Posted March 22, 2012 Oh no, once the hook is hooks table you can use it as usual. It is the problem getting it in to the table in the first place w/o manual insertion. Link to comment Share on other sites More sharing options...
mexique1 Posted March 22, 2012 Share Posted March 22, 2012 And what about this ? class SaveableHook extends HookCore { public $description; public $title; protected $fieldsRequired = array('name', 'description', 'title'); public function getFields() { $fields = parent::getFields(); $fields['description'] = pSQL($this->description); $fields['title'] = pSQL($this->title); return $fields; } } Not tested Link to comment Share on other sites More sharing options...
Mark Hesketh Posted March 22, 2012 Share Posted March 22, 2012 You guys are really making me realise I've been slacking off on Prestashop development and there's a lot that can be done. Eagerly following your posts! Link to comment Share on other sites More sharing options...
phrasespot Posted March 22, 2012 Share Posted March 22, 2012 And what about this ? Yep, that would do, only I would name the class Hook so you could drop into overrides and maybe add the remaining columns of the table as fields as well. class Hook extends HookCore { public $description; public $title; ... Link to comment Share on other sites More sharing options...
Fabien Serny Posted March 23, 2012 Author Share Posted March 23, 2012 I'm not sure what you are trying to do guys, but in 1.5 you do not need to make manual insertion for hooks anymore. Link to comment Share on other sites More sharing options...
Dev On Web Posted March 23, 2012 Share Posted March 23, 2012 I'm not sure what you are trying to do guys, but in 1.5 you do not need to make manual insertion for hooks anymore. Sure, just override the FrontController and assign the new hook right ? Link to comment Share on other sites More sharing options...
strapper Posted April 3, 2012 Share Posted April 3, 2012 Hello Fabien, i asked for this special system hook : http://forge.prestashop.com/browse/PSFV-713 it could be useful for all batches tasks, both in prestashop core and in modules. please have a look Link to comment Share on other sites More sharing options...
ruilong Posted April 11, 2012 Share Posted April 11, 2012 I'm not sure what you are trying to do guys, but in 1.5 you do not need to make manual insertion for hooks anymore. Hi Fabien, I got an idea, maybe it's too much to implement in 1.5, but I was thinking like this. 1. Add a hook in "init", make it possible to use a global variable here, lets call it $getConfigurations array. 2. Then in the modules, we hook them to init and populate this array with the configuration values we need, like say $getConfiguration[] = 'PS_SHOP_NAME'; 3. in the init function, you then do a Configuration::getMultiple with all values from getConfiguration array and store this in a global variable like say $shopConfiguration['PS_SHOP_NAME']. this can then be accessed from all modules and even from the pages controllers, this should remove many of the dupliacate Configuration::get and the need for modules to make extra selects from the database. I think this would speed up Prestashop a bit. What do you think? Link to comment Share on other sites More sharing options...
loly Posted April 25, 2012 Share Posted April 25, 2012 I'm not sure what you are trying to do guys, but in 1.5 you do not need to make manual insertion for hooks anymore. Please tell more about how to add new hook in 1.5 ! Link to comment Share on other sites More sharing options...
Dev On Web Posted April 26, 2012 Share Posted April 26, 2012 Just override the FrontController Class then add your hook in TPL Link to comment Share on other sites More sharing options...
Fabien Serny Posted April 26, 2012 Author Share Posted April 26, 2012 Why do you want to override FrontController Class to add hooks ? Link to comment Share on other sites More sharing options...
Dev On Web Posted April 26, 2012 Share Posted April 26, 2012 Hmm not? Ex : if ($this->context->getMobileDevice() == false) { $this->context->smarty->assign(array( 'HOOK_HEADER' => Hook::exec('displayHeader'), 'HOOK_NEW' => Hook::exec('myNewBlock'), 'HOOK_TOP' => Hook::exec('displayTop'), 'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''), 'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''), 'currentController' => get_class($this->context->controller), )); } else { $this->context->smarty->assign(array( 'HOOK_MOBILE_HEADER' => Hook::exec('displayMobileHeader'), 'currentController' => get_class($this->context->controller), )); } Link to comment Share on other sites More sharing options...
Fabien Serny Posted April 26, 2012 Author Share Posted April 26, 2012 Now you can execute a hook directly in your tpl by writing this {hook h='nameOfYourHook'} You don't need anymore to override, and I understand that these lines are confusing because they don't respect the last standard of 1.5). We should / will change these lines. Link to comment Share on other sites More sharing options...
Dev On Web Posted April 26, 2012 Share Posted April 26, 2012 Ha ok! Thankx for this information I go to change that. Link to comment Share on other sites More sharing options...
Promokit Posted May 8, 2012 Share Posted May 8, 2012 Now you can execute a hook directly in your tpl by writing this {hook h='nameOfYourHook'} You don't need anymore to override, and I understand that these lines are confusing because they don't respect the last standard of 1.5). We should / will change these lines. Hi Fabien. This trick don't work for me. In Install function of module I added a line: $this->registerHook('layeredNav') In the back office I transplanted my module to this hook "layeredNav" and in tpl file i added a line: {hook h='layeredNav'} but my module don't appeared in needed place. P.S. sorry for my bad english) Link to comment Share on other sites More sharing options...
strapper Posted May 8, 2012 Share Posted May 8, 2012 works for me on the svn version that's great ! Link to comment Share on other sites More sharing options...
Promokit Posted May 9, 2012 Share Posted May 9, 2012 I'm just forgot the function public function hooklayeredNav($params) { return $this->hookFooter($params); } Link to comment Share on other sites More sharing options...
Yannkee Posted June 26, 2012 Share Posted June 26, 2012 Hello, Anybody can explain me how to add a new Hook in 1.5 ? I want to hook center content on a few pages. I tried the 1.4 method but not works, I spent a lot of time searching through the forums and more but did not find... Thanks. Link to comment Share on other sites More sharing options...
wingover Posted June 27, 2012 Share Posted June 27, 2012 Hi, thank you for this information - it's easy now, to insert own hooks with {hook h='nameOfYourHook'}. Is there any other way to enable own hooks in modules? To enable a hook for a module, this code in the module is nessesary, right? public function nameOfYourHook($params) { return $this->hooksomeDefaultHook($params); } Is ist possible to override the php-class or better an extra config-file / settings to enable hooks for modules. Maybe a part in the theme config.xml like: <hooks> <blocksearch available="nameOfYourHook" /> </hooks> That would be a nice function and better for module-updates... Link to comment Share on other sites More sharing options...
J. Danse Posted July 13, 2012 Share Posted July 13, 2012 Hi, I added new hooks, amongst it, there were some hooks you asked for : - actionAdminOrdersTrackingNumberUpdate - actionPasswordRenew - actionModuleMailAlertSendCustomer - displayAdminCategoriesForm I just commited them, I'll let you test Hi, where are these hooks ? I don't find them... :-/ Link to comment Share on other sites More sharing options...
Rhobur Posted July 14, 2012 Share Posted July 14, 2012 Hi, Wouldn't be nice to have a hook for the CMS pages ? Sometime you need to add a slider there for example. Have a nice weekend everybody ! Link to comment Share on other sites More sharing options...
Recommended Posts