WHMCS Base URL Template Variable

From WHMCS Documentation

Revision as of 12:26, 10 November 2020 by AlexN (talk | contribs)

The WHMCS Base URL must be defined in all client side template files for javascript ajax calls to function correctly, it determines the path to the WHMCS directory on your server. It is required for WHMCS to determine where relative resources required by the template are located.

If this variable is not defined in your active system template then you will see a warning notice in the browser console as follows:

Warning: The WHMCS Base URL definition is missing from your active template. Please refer to https://docs.whmcs.com/WHMCS_Base_URL_Template_Variable for more information and details of how to resolve this warning.

To resolve this warning, you must add the following to the <head> section of your template:

<script> var whmcsBaseUrl = "{\WHMCS\Utility\Environment\WebHelper::getBaseUrl()}"; </script>

It is important that this variable is defined before the templates scripts.min.js file is included.

By default, the Six template defines this parameter within the /includes/head.tpl template file along with a number of other required javascript variables.

You can refer to https://github.com/WHMCS/templates-six/blob/master/includes/head.tpl for a copy of the latest version of the head.tpl template file.