SeanP Posted February 2, 2021 Share Posted February 2, 2021 Is there a list of template files and the corresponding hooks that execute when that template is called? I am going through the hook index documentation, but it's not always easy to figure out which hook to use on a specific template. I am upgrading an old version of WHMCS, and moving code from {php} tags in templates to hooks. For instance, I need to create hooks for the following template files in the shopping cart: complete.tpl configureproduct.tpl products.tpl viewcart.tpl They are not specific to a particular function, I just need to run hooks to generate template tags for each of those templates. 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted February 2, 2021 Author Share Posted February 2, 2021 I found the following post, and assume this would work for each of the templates I listed: 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 3, 2021 Share Posted February 3, 2021 14 hours ago, SeanP said: Is there a list of template files and the corresponding hooks that execute when that template is called? not specifically - I mean there is the hook index - https://developers.whmcs.com/hooks/hook-index/ - but a lot of this is just common sense (or i've been doing this far too long and just remember what works where!). for example, on the client area side, ClientAreaPage will be called on (nearly) every template - so in the above example, you could either use CAP or ClientAreaPageCart (which only runs on cart pages)... either way, you're going to going to add conditions for each of the four templates... e.g you won't necessarily need 4 separate hooks for above (though you can if you prefer), but one hook containing four conditions based on what the current template is... if products, do this; if complete do that (though there is a ShoppingCartCheckoutCompletePage hook point for complete depending on if you want to return html or not); if viewcart, do something x etc.. only one of those conditions will be true at any one time. almost certainly, whatever you want to do in these hooks, there will be working examples posted in these forums that will be similar or should at least point you in the right direction... granted, you might not know what to search for.... searching for ClientAreaPageCart and my name as poster should find you many of the cart hooks that i've posted.... though for anything specific, let me know and I can search my hooks locally (publicly posted, private or commercial). 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted February 4, 2021 Author Share Posted February 4, 2021 10 hours ago, brian! said: not specifically - I mean there is the hook index - https://developers.whmcs.com/hooks/hook-index/ - but a lot of this is just common sense (or i've been doing this far too long and just remember what works where!). for example, on the client area side, ClientAreaPage will be called on (nearly) every template - so in the above example, you could either use CAP or ClientAreaPageCart (which only runs on cart pages)... either way, you're going to going to add conditions for each of the four templates... e.g you won't necessarily need 4 separate hooks for above (though you can if you prefer), but one hook containing four conditions based on what the current template is... if products, do this; if complete do that (though there is a ShoppingCartCheckoutCompletePage hook point for complete depending on if you want to return html or not); if viewcart, do something x etc.. only one of those conditions will be true at any one time. almost certainly, whatever you want to do in these hooks, there will be working examples posted in these forums that will be similar or should at least point you in the right direction... granted, you might not know what to search for.... searching for ClientAreaPageCart and my name as poster should find you many of the cart hooks that i've posted.... though for anything specific, let me know and I can search my hooks locally (publicly posted, private or commercial). Thanks for all the help! I'm starting to figure out where things are. I've gotten most of my code moved to modules/hooks now. Based on what you just said, it sounds like I'm on the right track and using the correct hook points. 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.