Difference between revisions of "Working with Module Templates"

From WHMCS Documentation

(Created page with "Modules that provide user facing output typically use templates to define and control that output. There are some exceptions, most often in the case of older modules, but all...")
(No difference)

Revision as of 13:55, 22 June 2015

Modules that provide user facing output typically use templates to define and control that output. There are some exceptions, most often in the case of older modules, but all recent modules should be using templates.

How Templates Work

Module template files can exist in either the root directory of the module, or in a subfolder named "templates".

In addition, modules can ship with template files that are designed for specific templates. For example, in the case of the Licensing Addon module that we ship with WHMCS, we provide two templates, /modules/servers/licensing/templates/managelicense.tpl which is optimised and designed for Version 6 and specifically the six template and custom templates based on that. But in addition, we also provide a /modules/servers/licensing/templates/five/managelicense.tpl template file which is optimised and designed for the Version 5 "five" template.

If your custom theme is based on the five template, you would likely want to consider using the overrides system below to have your custom template define the version optimised for five is used.

Customising Templates

Module templates can be customised using an overrides system that allows customisations to be performed within your active client area template theme folder.

Recommended This functionality was introduced in WHMCS 6.0 and is present in 6.0.0-rc.1 and later.

The advantages of customising module templates this way is that your customisations remain unaffected through upgrades, and all of your customisations become portable and possible to backup as part of your custom template folder.

To create an override template, simply make a copy of the original template file within the following folder structure inside your custom template: /templates/yourtemplatename/modules/moduletype/modulename/.

For example, in the case of the provisioning module "cpanel", /modules/servers/cpanel/overview.tpl could be customised by creating the following template file: /templates/yourtemplatename/modules/servers/cpanel/overview.tpl

Another example, this time based upon the provisioning module "licensing", /modules/servers/licensing/templates/managelicense.tpl can be customised by creating the following template file /templates/yourtemplatename/modules/servers/licensing/managelicense.tpl

The same thing applies to addon modules too. For example the client area view template located in /modules/addons/project_management/templates/clientview.tpl' could be customised by creating the template file /templates/yourtemplatename/modules/project_management/templates/clientview.tpl.