2013-10-09 50 views
1

我試圖在cakephp中創建一個新的自定義處理程序。它不適合我。當他嘗試訪問無法訪問/限制的url時,我需要向用戶顯示自定義消息。現在蛋糕顯示內部服務器錯誤,但我需要顯示自定義消息與他的可訪問的頁面鏈接。我需要拋出異常/Lib/...php在cakephp中創建自定義異常處理程序和自定義錯誤模板

謝謝你提前。

回答

2

您可以創建在CakePHP的2.x的自定義異常處理程序看到此鏈接

http://book.cakephp.org/2.0/en/development/exceptions.html#create-your-own-exception-handler-with-exception-handler

http://book.cakephp.org/2.0/en/development/exceptions.html#using-a-custom-renderer-with-exception-renderer-to-handle-application-exceptions

可以在beforeRender的AppController

的改變佈局()
public function beforeRender(){ 
    if($this->name == 'CakeError'){ 
     $this->layout = 'error'; 
    }   
} 
+0

謝謝您。現在它爲我工作... – user1621860