jimlongo Posted September 29, 2020 Share Posted September 29, 2020 I'm landing on a page that looks like mywhmcs.com/cart.php?a=confproduct I need to do some work and ouput some html or javascript in my addon module. I've tried a bunch of hooks in '/addons/mymodule/hooks.php', can't find one that ouputs to the body of the page. Thanks. 0 Quote Link to comment Share on other sites More sharing options...
jimlongo Posted September 30, 2020 Author Share Posted September 30, 2020 (edited) Let me rephrase my question. I'm a little confused by the documentation about hooks. Originally this module was inherited from a well known developer of modules. It has both "/addons/MyModule/hooks.php" and "/servers/MyModule/hooks.php" files. The functions and hooks in "/servers/MyModule/hooks.php" are the ones that have stopped firing. Looking through the activity log, i don't even see an attempt to load this file. Q: what is the difference between these 2 files and "/includes/hooks/MyModule.php" ? Because when I move the hooks from /servers/ to /includes/ they now fire as I would expect. For instance ClientAreaPageCart hook now fires when I'm on the page. What are the reasons for having the various places to put hooks? Edited September 30, 2020 by jimlongo 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted October 1, 2020 Share Posted October 1, 2020 I suspect you created hooks.php file when the module was already activated. In this case your file is ignored as WHMCS detects it only on module activation. You have two options: Deactivate and reactivate the module In tblconfiguration there's a setting that stores a comma separated list of modules that are using hooks.php. I can't remember the exact name of tblconfiguration.setting but it should be something like "ModuleHooks". Add you module to the list and save 0 Quote Link to comment Share on other sites More sharing options...
jimlongo Posted October 1, 2020 Author Share Posted October 1, 2020 (edited) @Kian Thank you. No that's not the case, and thank you I did know that you need to deactivate-reactivate the module when making changes. The information i'm really looking for is an explanation of what the various hooks files should be used for. Surely it's not just a matter of use whichever one you want. We have servers/mymodule/hooks.php, addons/mymodule/hooks.php and includes/hooks/anything.php, I think this requires some explanation in the docs. https://developers.whmcs.com/hooks/getting-started/ Regarding your second bullet, I have tblconfiguration.ModuleHooks.value = cpanel,plesk Edited October 1, 2020 by jimlongo 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 1, 2020 Share Posted October 1, 2020 17 minutes ago, jimlongo said: We have servers/mymodule/hooks.php, that's a provisioning module - https://developers.whmcs.com/provisioning-modules/ 17 minutes ago, jimlongo said: addons/mymodule/hooks.php that's an addon module - https://developers.whmcs.com/addon-modules/ 18 minutes ago, jimlongo said: includes/hooks/anything.php hooks without a module. 🙂 0 Quote Link to comment Share on other sites More sharing options...
jimlongo Posted October 1, 2020 Author Share Posted October 1, 2020 (edited) @brian!Thank you. Perhaps you could expand a little bit. My module acts within WHMCS pages( adding UI, adjusting prices, expecting input), I assume that's an add-on module? Sometimes it is provisioning services (for instance when an order has been placed and submitted), I guess a provisioning module. hooks without a module . . . would I ever need this? Edited October 1, 2020 by jimlongo 0 Quote Link to comment Share on other sites More sharing options...
jimlongo Posted October 1, 2020 Author Share Posted October 1, 2020 18 hours ago, Kian said: In tblconfiguration there's a setting that stores a comma separated list of modules that are using hooks.php. I can't remember the exact name of tblconfiguration.setting but it should be something like "ModuleHooks". Add you module to the list and save This is correct. Somehow my module had been removed from the list. if it's in the list then WHMCS looks for the hooks in /servers/MyModule/hooks.php There may be another way (besides manually) to get it in the list, but I found that by "resaving" any of the Products/Services that uses my module (Product>Module Settings), it was put back in the list. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 2, 2020 Share Posted October 2, 2020 19 hours ago, jimlongo said: Perhaps you could expand a little bit. My module acts within WHMCS pages( adding UI, adjusting prices, expecting input), I assume that's an add-on module? it's location tells you what it is - or should do. 🙂 19 hours ago, jimlongo said: hooks without a module . . . would I ever need this? probably often... I mean, if you were coding a navbar hook to change the a menu in the client area, you wouldn't necessarily create an addon module just for that simple purpose - you could and it would work, but i'd consider it overkill. I think most of the hooks posted in this place will be for the /includes/hooks directory - though that doesn't mean that they can't also be used in addon modules too. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.