Difference between revisions of "WHMCS Base URL Template Variable"

From WHMCS Documentation

Line 4: Line 4:
  
 
<div class="docs-alert-warning">
 
<div class="docs-alert-warning">
Warning: The WHMCS Base URL definition is missing from your active template. Please refer to [WHMCS_Base_URL_Template_Variable] for more information and details of how to resolve this warning.
+
Warning: The WHMCS Base URL definition is missing from your active template. Please refer to [[WHMCS_Base_URL_Template_Variable|WHMCS Base URL Template Variable]] for more information and details of how to resolve this warning.
 
</div>
 
</div>
  

Revision as of 22:45, 20 November 2020

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 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 Twenty-One and Six system themes define this parameter and many other required JavaScript variables in the /includes/head.tpl system theme template.

Client Area Templates
We introduced Twenty-One in WHMCS 8.1. We plan to remove Six in a future version.

See our GitHub repository for a copy of the latest version of the /includes/head.tpl system theme template file.