Jump to content

How to update template content from addon module


C1212

Recommended Posts

I am new to WHMCS addon module development, forgive me if I am asking this wrongly.

I am working on an addon module that works with support tickets.

I would like to add a checkbox to the submit ticket form in the client area. When checked, would be treated differently in the module hook.

But that checkbox should not show on the client area page if the module isn't enabled/activated.

The hook point 'ClientAreaPageSubmitTicket'  allows returning  key/value pairs to be made available as additional Smarty template parameters. Which can then be used in the theme template file. I would like not to edit the template file so that the addon module can easily be used on different themes.

What is the best way to update the content of template from addon modules without editing the template files?

Link to comment
Share on other sites

I am now using "ClientAreaHeadOutput" hook.
Essentially, I use this hoop point to inject form input elements to the form on `submitticket` page.

add_hook('ClientAreaHeadOutput', 10, function($vars){
    if($vars['filename'] === 'submitticket'){
        return <<<HTML
    <script type="text/javascript">
        $(function() {
            $("#customFieldsContainer").append('<div class="section"><div class="section-header"><h2 class="section-title">Section title</h2></div></div>');
            
        })
    </script>
HTML;
        
    }
});

Just wondering is this is recommended way. Would appreciate other suggestions.

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.

×
×
  • 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