Jump to content

Hook call order


Recommended Posts

Hi all
let's assume we have 2 modules that uses the same hook, in example "displayHeader"

Any way to force the load order for these 2 modules, without manually change the position from the backoffice ?

What i need to do is that moduleB is ALWAYS loaded after moduleA, if installed.

As workaround that i'm thinking right now when writing is to create a new hook in moduleA, and moduleB attach to this new hook. BUT what happens if moduleA is not installed or installed after the moduleB ?

In other words:

module A and module B has indipendent modules that can be installed alone.

If module A is not installed, module B can safely attach to "displayHeader"

If module A is installed (before or after) module B, then module B should attach to displayHeader *always* after module A displayHeader. OR, as wrote above, module B should attach to the custom hook created by module A.

AFAIK hoot attach is done during the module install, so I don't know how to change the behaviour of module B based on module A, if module A is installed after module B.

 

Any idea ?

 

Link to comment
Share on other sites

10 minutes ago, Prestashop Addict said:

At install change hook module position directly in databse

Uhm, so probably the best solution would be to force position of module B to "99" (the max value field position could take, as it's a 2 char tinyint) and force position of module A to 98.

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...