Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Tuesday, February 8, 2011

How To Customize Main Layout of Error Pages in cakePHP

To customize the contents of each cakePHP errors, you need to create the following pages in this folder /app/views/errors/
- error404.ctp
- missing_action.ctp
- missing_component_class.ctp
- missing_component_file.ctp
- missing_connection.ctp
- missing_controller.ctp
- missing_helper_class.ctp
- missing_helper_file.ctp
- missing_layout.ctp
- missing_model.ctp
- missing_scaffolddb.ctp
- missing_table.ctp
- missing_view.ctp
- private_action.ctp
- scaffold_error.ctp


But cakePHP is using /views/layouts/default.ctp as layout for these error pages like 404, missing controller, etc. To customize it, you need to create a file /app/app_error.php with the following contents:
class AppError extends ErrorHandler {
 
 function _outputMessage($template) {
  $this->controller->layout = 'error_template'; // /app/views/layouts/error_template.ctp
  parent::_outputMessage($template);
 }

}

And create a template file "error_template.ctp" in /app/views/layouts.

Hope this one helps.

Tuesday, November 24, 2009

Cannot send session cache limiter

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

If you encounter the above problem, try to set the encoding from UTF-8. UTF-8 encoidng add some characters before <?php