brennino Posted April 7, 2014 Share Posted April 7, 2014 Hi, I have successfully created a new hook that allow me to place my modules inside header.tpl. I can also see my new hook in the module->positions of the backend. My problem is that I want to place blockcart and blocksearch inside my new hook and I get the error: "This module cannot be transplanted to this hook." This is the behaviour that I aspect from prestashop because not all modules can be transplanted in all hook, especially if the hook is a custom one and the module can't know it. I think that one way to place cart and search block inside a custom hook is to change the module code and register my new hook. This is bad for module update reasons because both search and cart are core modules. How to achieve this without touching core code? Thanks Marco Link to comment Share on other sites More sharing options...
vekia Posted April 7, 2014 Share Posted April 7, 2014 in this case you have to create function to handle this new hook (in your module .php file) public function hookYourHookName($params) Link to comment Share on other sites More sharing options...
brennino Posted April 7, 2014 Author Share Posted April 7, 2014 Thanks for the reply, ok, I think I get what you mean but let me give you an example for make me more understandable. I have follow this steps: - I create my custom module and create my hook following the steps in this tutorial. - I place my new hook on a tpl file. - I edit blocksearch.php (because I want to show the quick search in my new hook) public function install() { if (!parent::install() || !$this->registerHook('top') || !$this->registerHook('header') || !$this->registerHook('displayMobileTopSiteMap') || !$this->registerHook('displayCustomTopHook')) return false; return true; } public function hookDisplayCustomTopHook($params) { return $this->hookLeftColumn($params); } - I transplant the "quick search" module under my new hook and everything works. Now assume this situation: - There is an update of the core quick search module - I update the module I suppose the quick search will not appear anymore under my custom hook, because the code revert to a version that doesn't know my hook. My question is: Is there a way for avoid to hack blocksearch.php so that I havn't to patch the core code everytime I update "quick search module"? The better way I think that can be to tell prestashop inside my custom module (that has the new hook) and not inside quicksearch: Hey, inside this hook you can place also quick search! I came from a Drupal behaviour where I define regions and I can place the code I want inside that regions without braking the system after updates. Thanks Marco Link to comment Share on other sites More sharing options...
Recommended Posts