Difference between revisions of "WHMCS Base URL Template Variable"

From WHMCS Documentation

m
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
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.
+
The [[General Tab|WHMCS System URL]] must be defined in all system theme template files for JavaScript AJAX calls to function correctly. It determines the path to the WHMCS directory on your server. WHMCS requires this in order to determine the location of relative resources that the system theme template requires.
 
+
If this variable is not defined in your active system template then you will see a warning notice in the browser console as follows:
+
If this variable is not defined in your active system theme template, you will see a warning in the browser console:
 
+
<div class="docs-alert-warning">
+
<div class="source-cli">
 
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.
 
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.
 
</div>
 
</div>
 
+
To resolve this warning, you must add the following to the ''<head>'' section of your template:
+
To resolve this warning, you must add the following to the <tt><head></tt> section of your template:
 
+
 
<div class="source-cli">
 
<div class="source-cli">
 
<script>
 
<script>
var whmcsBaseUrl = "{\WHMCS\Utility\Environment\WebHelper::getBaseUrl()}";
+
<br/>var whmcsBaseUrl = "{\WHMCS\Utility\Environment\WebHelper::getBaseUrl()}";
</script>
+
<br/></script>
 
</div>
 
</div>
 
+
It is important that this variable is defined before the templates ''scripts.min.js'' file is included.
+
It is important that this variable is defined before the templates <tt>scripts.min.js</tt> 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.
+
By default, the Six template defines this parameter within the <tt>/includes/head.tpl</tt> system theme 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.
+
[https://github.com/WHMCS/templates-six/blob/master/includes/head.tpl Visit GitHub] for a copy of the latest version of the <tt>head.tpl</tt> template file for the Six theme, or look in the appropriate directories in your WHMCS installation for Twenty-One.

Latest revision as of 12:54, 24 May 2023

The WHMCS System URL must be defined in all system theme template files for JavaScript AJAX calls to function correctly. It determines the path to the WHMCS directory on your server. WHMCS requires this in order to determine the location of relative resources that the system theme template requires.

If this variable is not defined in your active system theme template, you will see a warning in the browser console:

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 system theme template file along with a number of other required JavaScript variables.

Visit GitHub for a copy of the latest version of the head.tpl template file for the Six theme, or look in the appropriate directories in your WHMCS installation for Twenty-One.