Jump to content

[SOLVED] change display hook of two modules prestashop 1.7


Recommended Posts

Hi @khalilgrom,

If I understand well, you just need to unhook megamenu and re-hook it to the hook where Search module is. Then do the same for Search module.

When you're in Apparence > Positions, for each module you have a Modify button and an arrow, click on that one to access the unhook (not sure of the English name) function.

Then on same screen, top right, you shoud have two buttons "Hook" and "Help" (again not sure about the name), use the Hook button to select your module and the hook you want for it to be displayed.

Hope it helps!

Link to comment
Share on other sites

I reckon you'll need to override this module to register the hook you want. But I'm not entirely sure as I'm a beginner in PrestaShop! And maybe the module is not ready to be hooked somewhere else.

First method is to find the module folder under modules in your project. Under the function install() you should see the hook registration. It should look something like this:

public function install()
{
  return parent::install() &&
  $this->registerHook('header') &&
  $this->registerHook('displayBanner');
}

You can try to add the hook you want. You might need to uninstall and reinstall the module to see the change. Be aware that this solution will be lost if you update the module.


Other way to try to do this and still be able to update the module is to override it.
You can try to add a new PHP file under override > modules > name_of_your_module > name_of_your_module.php

In the file you created, you start with:

<?php

if (!defined('_PS_VERSION_'))
  exit;

class Ps_NameOfModuleOverride extends Ps_NameOfModule
{
}

Then you override here the install function.

Again I'm a beginner so I'm not sure if it this will work. :)

Edited by Minsky_ae (see edit history)
  • Like 1
Link to comment
Share on other sites

thanks  bro,  without reinstall module, I have added  this function (and copy paste content from hookDisplayMegamenu function) in 'posmegamenu.php' file and the hook function appear in position page of module and I choose it

public function hookDisplaySearchTop()

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...