How can we improve WHMCS?

Share, discuss and vote for what you would like to see added to WHMCS

Hook return issues including more then one hook point compatibility and changes to smarty variables

The issue at hand here is what happens with the return data from a hook point. I want it to be official that a hook can change smarty template variables so that changes to the default WHMCS templates can be made without editing the included WHMCS templates. This will allow the WHMCS updater to update whmcs and the default templates, while being able to make basic changes to the template by changing the smarty templates sent to the template. Making changes to smarty/template/whmcs variables from within a hook, allows for code changes of a template without having to modify the WHMCS provided template, thus when updates come out, the templates stay up to date without merging/fixing of custom changes.

When you change the smarty templates via hook return data, having more then one hook using the hook point (for example ClientAreaPage) even with different priorities, to change whmcs variables including smarty template variables in the array that is passed to the hook function does not work as one would assume. The array argument getting passed to any subsequent hook for the same hook point is getting reset and any changes made in the first hook function results do not get passed into any subsequent hook function.

When the first hook (by priority) changes one variable for hook point example ClientAreaPage and then another hook changing a completely different variable for hook point example ClientAreaPage, the highest priority hook return variables are the only ones changed, and any lower priority hook variables are not changed at all. Thus the subsequent hooks do nothing to template or whmcs variables, while only highest priority hook actually preforms as indented and can adjust the built in whmcs variables and smarty template variables.

This behavior would occur in any third party module when you have module A calling hook ClientAreaPage to change variable A and then another third party module B calling hook ClientAreaPage to change variable B. Only the hook point with the highest priority would be able to change any whmcs variables passed to the function and would show on the template where as the lower priority would not.

The ability of merging the results of more then one hook calling the same hook point allows both to set variables if needed. The lowest priority hook changes what variables it needs, and subsequent hooks see the all the whmcs variables including the previous hooks changes/additional variables made. This ability for example allows one hook to change the logo and another other hook to change the company for example, both work. In your current code, if the hook that changes the company is higher then the hook that changed the logo, then the logo change doesnt work, only the company change goes to the template from the higher hook.

So to summarize, I would like the ability for hook result variable merging and official support of whmcs and smarty template variables changing (not just additional variables) to allow more programmer flexibility including when more then one hook file calls the same hook point to change variables (not just add additional variables).

Post the first comment

Login to post a comment.