Jump to content

How to add a native hook to a module ?


AcidLava

Recommended Posts

Hello,

I'd like to hook ps_langageselector and ps_currencyselector on displayHeader.

Unfortunately, it seems that all the hooks are available except this one. I'm looking for a way to add this hook but I can't find any clear tutorial about adding a native hook to a module on PS 1.7.

Could you please help ?

Thanks.

Edited by AcidLava (see edit history)
Link to comment
Share on other sites

Hello Mediacom87, thanks for your time.

I've seen this one but it's not very clear to me. In my case and for example, I make a folder ps_languageselector in override/modules, then a file ps_languageselector.php.

In the .php file I write :

public function install()
 {
     $this->registerHook('displayHeader');
 }

 public function hookDisplayHeader(array $params)
 {
     // Your code.
 }

What I am supposed to add in "Your code" ?

Thanks.

Edited by AcidLava (see edit history)
Link to comment
Share on other sites

il y a une heure, AcidLava a dit :

😐

What do you want to do in displayHeader hook ?

this hook is to put something before body tag, like for script or meta or css. But for script or css you need to use another solution.

if you don’t clearly take time to explain clearly whet you want you can’t received a really interesting answer.

Link to comment
Share on other sites

  • 1 year later...

if the hook already exists, there's a simple solution.

add them in the database.

first search for the module id for the module you want. that would be on table ps_module.

then search for the id of the hook you'd like to hook the module to. it's in table ps_hook.

then once you have all that information it's just a matter of adding them to the proper table, ps_hook_module

if you have more modules hooked on that same hook, you'll probably need to check the position. not sure if putting position 1 to that hook, when you already have another one on that position will cause any problems. it's a bit time consuming but it's sure to work.

 

Click on the ps_hook_module, then click "insert"

and enter the id_module

id_shop (should be 1, unless you have multi-store)

id_hook

position

 

click go, and enjoy :)

Edited by patuga (see edit history)
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...