タグ

ブックマーク / www.happytrap.jp (1)

  • [CakePHP] 例外時のレイアウトファイル変更 | HAPPY*TRAP

    CakePHPで例外を投げた時のレイアウトファイルを変更する方法です。 やり方はいろいろあると思いますが、今回は、ExceptionRendererクラスのサブクラスAppExceptionRendererを新規に作成して、出力時にレイアウトファイルを変更してみます。 app/Lib/Error/AppExceptionRenderer.php1 2 3 4 5 6 7 8 <?php App::uses('ExceptionRenderer', 'Error'); class AppExceptionRenderer extends ExceptionRenderer { protected function _outputMessage($template) { $this->controller->layout = 'custom'; // ここでレイアウトファイルを指定

  • 1