Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: “Use of undefined constant” error in OpenCart  (Read 5667 times)

0 Members and 1 Guest are viewing this topic.

sajugovind

  • Guest
“Use of undefined constant” error in OpenCart
« on: August 10, 2014, 01:47:22 am »
Cx getting a blank page after upgrading to a newer version of OpenCart.

In the error log, I found the following errors.

Code: [Select]
Notice: Use of undefined constant DIR_TEMPLATE - assumed 'DIR_TEMPLATE' in /home/ellex168/public_html/catalog/controller/common/home.php on line 9Notice: Use of undefined constant DIR_TEMPLATE - assumed 'DIR_TEMPLATE' in /home/ellex168/public_html/catalog/controller/common/column_left.php on line 79Notice: Use of undefined constant DIR_TEMPLATE - assumed 'DIR_TEMPLATE' in /home/ellex168/public_html/vqmod/vqcache/vq2-system_engine_controller.php on line 92Notice: Use of undefined constant DIR_TEMPLATE - assumed 'DIR_TEMPLATE' in /home/ellex168/public_html/vqmod/vqcache/vq2-system_engine_controller.php on line 107Notice: Error: Could not load template DIR_TEMPLATEdefault/template/common/column_left.tpl! in /home/ellex168/public_html/vqmod/vqcache/vq2-system_engine_controller.php on line 107

Causes of error?

As I mentioned earlier, this issue normally happen after updating or upgrading the OpenCart and most probably because of the “vqmod” in OpenCart.

“vQmode” (aka Virtual Quick Mod) is an override system designed to avoid having to change core files. The concept is quite simple. Instead of making changes to the core files directly, the changes are created as xml search/replace script files. These script files are parsed during page load as each “source” core file is loaded with the “include” or “require” php functions. The source is then patched with the script file changes, and saved to a temp file. That temp file is then substituted for the original during execution. The original source file is never altered. This results in a “virtual” change to the core during execution without any actual modification to the core files.

So after upgrade or update, the constant value will remain same or it will left blank or will be removed from the config file and result the error mentioned above.

 

How to fix?

From the error, it is clear that the constant value “DIR_TEMPLATE” is defined wrong or it is not defined at all. So to fix the issue, we need to define this constant in the config file of OpenCart which is “config.php” file found in the document root.

If you google, you will get sample config.php files of OpenCart and you could find that the “DIR_TEMPLATE” constant is defined as below.

Code: [Select]
define('DIR_TEMPLATE', '/home/user/folder/www.site.com/catalog/view/theme/');
As you can see, the constant value “DIR_TEMPLATE” is use to point to the “theme” directory which can found under the catalog folder of your OpenCart site.

Add the above line in the config.php and set the correct path and that will fix the issue!

Thank you........