Renaming a hook so its always the last one used

Ask the community for help and support.
Post Reply
14Steve14
VIP Member
VIP Member
Posts: 549
Joined: Fri Oct 25, 2019 7:01 pm
Has thanked: 8 times
Been thanked: 49 times

Renaming a hook so its always the last one used

Post by 14Steve14 »

I have two addons installed that are causing problems with each other. One is the images in their own folder module, and the other is an automatic stock update module that has been coded for me. They both use the same hook but the images one needs to come last, if that makes any sense.

How do I rename the hook to move it to the end. carts suggested adding a z to the name but where does that need to go. Is it just the file name or every instance of the hook name in the file.

Sorry for the silly question but it would be nice to get these two hooks to play nice with each other.
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Renaming a hook so its always the last one used

Post by ecartz »

If your hooks are hook_admin_categories_blah in blah.php and hook_admin_siteWide_whatever.php in whatever.php and you want blah to run after whatever, then you could rename the first to hook_shop_siteWide_zz_blah in zz_blah.php

The file name needs to match the class name. Nothing should affect order other than those two things. You would have to rename every instance of the class name in the file, but it often only appears once.
14Steve14
VIP Member
VIP Member
Posts: 549
Joined: Fri Oct 25, 2019 7:01 pm
Has thanked: 8 times
Been thanked: 49 times

Re: Renaming a hook so its always the last one used

Post by 14Steve14 »

Thanks for the explanation. I will have to try this on my test store later. Personally think it easier to move the images one to the end by adding something in there as that's the one causing the trouble. Then it will be out the way for any other hooks that may get added over time. I will let you know how I get on.
Post Reply