in Elftronix

Fix Joomla 3.x “Undefined constant DS” or Blank Offline Page

This is how to fix the “Undefined constant DS” error using Joomla 3. In my case, the problem was that the offline page was blank (just a white page with no text on it). Only the “Site Offline” page stopped working, everything else was working fine.

System Error

In such cases, the first thing to do is to turn on error reporting:

Admin -> Global Configuration -> Server -> Error Reporting -> Maximum

Which resulted in the following output:

Notice: Use of undefined constant DS – assumed ‘DS’ in /home/user/public_html/templates/mytemplate/offline.php on line 16

Notice: Use of undefined constant DS – assumed ‘DS’ in /home/user/public_html/templates/mytemplate/offline.php on line 16

Notice: Use of undefined constant DS – assumed ‘DS’ in /home/user/public_html/templates/mytemplate/offline.php on line 16

Notice: Use of undefined constant DS – assumed ‘DS’ in /home/user/public_html/templates/mytemplate/offline.php on line 16

Warning: require_once(/home/user/public_htmlDStemplatesDSmytemplateDShelpersDSbt_helper.php): failed to open stream: No such file or directory in /home/user/public_html/templates/mytemplate/offline.php on line 17

Fatal error: require_once(): Failed opening required ‘/home/user/public_htmlDStemplatesDSmytemplateDShelpersDSbt_helper.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/user/public_html/templates/mytemplate/offline.php on line 17

This is because the DS constant has been removed from Joomla 3 and upwards.
The fix was to locate line 16 in “/home/user/public_html/templates/mytemplate/offline.php” and change the code from:

// BT Template Helper
$bt_helper = JPATH_BASE.DS.'templates'.DS.$this->template.DS.'helpers'.DS.'bt_helper.php';
require_once ($bt_helper);
$bt = new btTemplateHelper();

to:

// BT Template Helper
if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
$bt_helper = JPATH_BASE.DS.'templates'.DS.$this->template.DS.'helpers'.DS.'bt_helper.php';
require_once ($bt_helper);
$bt = new btTemplateHelper();

Thus DS has been replaced with DIRECTORY_SEPARATOR and should work now.

Working for you now?

Care and share, let's call it fair! -David

Twitter Button Facebook Button Google Button LinkedIn Button

Write a Comment

Comment