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

This is how to fix the “Undefined constant DS” error using Joomla 3.

Undefined Constant DS

In my case, the problem was that the offline page was blank (just a white page with no text on it). Although only the “Site Offline” page stopped working, the rest of the Joomla site was working fine — here’s a quick solution to the problem!

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?
Comments below are welcome indeed!

3 thoughts on “How to Fix Joomla 3.x “Undefined constant DS” or Blank Offline Page”

Leave a Comment