Skip to content

Commit

Permalink
Make the error templates path configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
vlakoff committed Apr 12, 2014
1 parent 119d94f commit cdf3dfa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
11 changes: 11 additions & 0 deletions application/config/config.php
Expand Up @@ -253,6 +253,17 @@
*/
$config['log_date_format'] = 'Y-m-d H:i:s';

/*
|--------------------------------------------------------------------------
| Error Templates Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/views/errors/ folder. Use a full server path with trailing slash.
|
*/
$config['error_templates_path'] = '';

/*
|--------------------------------------------------------------------------
| Cache Directory Path
Expand Down
17 changes: 15 additions & 2 deletions system/core/Exceptions.php
Expand Up @@ -44,6 +44,13 @@ class CI_Exceptions {
*/
public $ob_level;

/**
* Path to the error templates
*
* @var string
*/
protected $_templates_path;

/**
* List if available error levels
*
Expand Down Expand Up @@ -73,6 +80,12 @@ public function __construct()
{
$this->ob_level = ob_get_level();
// Note: Do not log messages from this constructor.

$config =& get_config();

$this->_templates_path = (isset($config['error_templates_path']) && $config['error_templates_path'] !== '')
? $config['error_templates_path']
: VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -162,7 +175,7 @@ public function show_error($heading, $message, $template = 'error_general', $sta
ob_end_flush();
}
ob_start();
include(VIEWPATH.'errors'.DIRECTORY_SEPARATOR.$template.'.php');
include($this->_templates_path.$template.'.php');
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
Expand Down Expand Up @@ -205,7 +218,7 @@ public function show_php_error($severity, $message, $filepath, $line)
ob_end_flush();
}
ob_start();
include(VIEWPATH.'errors'.DIRECTORY_SEPARATOR.$template.'.php');
include($this->_templates_path.$template.'.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelog.rst
Expand Up @@ -48,6 +48,7 @@ Release Date: Not Released
- Removed previously deprecated EXT constant.
- Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties.
- Moved error templates to *application/views/errors/*.
- Made error templates path configurable using ``$config['error_templates_path']``.
- Moved the Log class to *application/core/*
- Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per environment.
- Changed detection of ``$view_folder`` so that if it's not found in the current path, it will now also be searched for under the application folder.
Expand Down

0 comments on commit cdf3dfa

Please sign in to comment.