Cakephp - how to make error pages have its own layouts?

后端 未结 6 1377
被撕碎了的回忆
被撕碎了的回忆 2021-02-13 16:00

I wanna have a different layout for the page not found 404 page. How can i set a different layout for that page?

6条回答
  •  温柔的废话
    2021-02-13 16:26

    better to create an error.php file in your app folder

    class AppError extends ErrorHandler { 
        function error404($params) { 
                $this->controller->layout = 'error'; 
                parent::error404($params); 
        } 
    }
    

    so you can avoid the if-testing at EVERY page render that savants' solution introduces

提交回复
热议问题