By default CakePHP will use the default.ctp layout to display any error messages.
In some cases this may not be desirable as your default.ctp might contain navigational and design elements, CSS and JS files, which really take away from the way the error message is displayed.
Usually an error message should be displayed in a clean and simple layout that only focuses on the error itself.
Thankfully, the remedy for this is pretty simple…
First, create a new layout and call it error.ctp (place in the app/views/layouts, of course).
Then add this to your App Controller:
function beforeRender () {
$this->_setErrorLayout();
}
function _setErrorLayout() {
if($this->name == 'CakeError') {
$this->layout = 'error';
}
}
$this->_setErrorLayout();
}
function _setErrorLayout() {
if($this->name == 'CakeError') {
$this->layout = 'error';
}
}
That’s all folks.
P.S. Note, this is different than modifying error message views. For instructions on that, please look at the helpful instructions in the actual error message.
Pingback: CakePHP Digest #13 | PseudoCoder.com
Pingback: Dica Rápida – CakePHP – Personalizando as páginas de erros « Cauan Cabral – Geek
Pingback: Tweets that mention Give all of your error messages a different layout | nuts and bolts of cakephp -- Topsy.com
Pingback: CakePHP 2.0 change error layout for admin | Richard Willis-Owen