Jump to content

Hooks per template


SeanP

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated