Jack_mcs Posted September 10, 2019 Share Posted September 10, 2019 @burtIn one of the upgrades you added a call to hooks in the aaplication_top after the require('includes/functions/html_output.php'); statement. I'm wondering if am missing something in my understanding of hooks. I thought you had to initialize and call them. Is that not correct? If I add a hook to the hooks/shop/ directory it doesn't get called. So am I doing something wrong or just not understanding the use? Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
burt Posted September 10, 2019 Share Posted September 10, 2019 19 minutes ago, Jack_mcs said: @burtIn one of the upgrades you added a call to hooks in the aaplication_top after the require('includes/functions/html_output.php'); statement. I'm wondering if am missing something in my understanding of hooks. I thought you had to initialize and call them. Is that not correct? If I add a hook to the hooks/shop/ directory it doesn't get called. So am I doing something wrong or just not understanding the use? https://github.com/gburton/CE-Phoenix/blob/master/includes/application_top.php#L104-L106 These three lines "fire up" the Hooks System. You then need to; register your Hook call your Hook There is a pre-placed register; https://github.com/gburton/CE-Phoenix/blob/master/includes/application_top.php#L422 Which means that if you want to do something on (eg) conditions.php you can without performing a "register" (you would obviously still need to "call" your hook). For a fairly simple example of registering your own hook, and calling it, see; https://github.com/gburton/CE-Phoenix/blob/master/checkout_shipping.php#L15 andhttps://github.com/gburton/CE-Phoenix/blob/master/checkout_shipping.php#L335 Which works with; https://github.com/gburton/CE-Phoenix/blob/master/includes/hooks/shop/progress/progress_hooks.php Have a play. Hooks are very powerful, more so than Content Modules in my opinion. Link to comment Share on other sites More sharing options...
Jack_mcs Posted September 10, 2019 Author Share Posted September 10, 2019 7 minutes ago, burt said: You then need to; register your Hook call your Hook There is a pre-placed register; I probably wasn't clear. I know how to use hooks. My confusion is with trying to understand what the purpose of that statement is for. For example, let's say I normally include a require('some file') statement after the html_output statement. That would take one line. If I have to register and call the hook, it is two lines. The count doesn't matter. The point is that there doesn't seem to be an advantage in using it at that point in the code. I assumed that adding the hook there would prevent changes to the core code but that doesn't seem to be the case. Is that correct? I could see it would be useful if I was adding a large block of code there but for one line changes, it probably isn't. I'm not criticizing it being there - just trying to make sure I understand it. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
burt Posted September 10, 2019 Share Posted September 10, 2019 Hooks are there for the benefit of your addons not having to paste 20 lines of code where 1 or 2 lines of code will do. If you don't want to use a pre-placed hook, then you register & call your own. The 3 lines of code to which you refer...without those, hooks would not work at all. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.