errorhandler views

Hello everyone,

I'd like to ask you whether is there in Yii any possibility to show HTTP errors (404 generally) in layout content area, not view/system white page with "Page not found" heading or other error. If not, is there any way to access some Controller from errorhandler?

The general guideline is that the error view should remain as simple as possible because it is being executed in an error environment and should not trigger any new errors. Therefore, layout is not supported because the layout may cause errors.

You may use Yii::app()->controller to access the current controller instance, if it is available.

thanks for advice

it took me quite long to parse layout script (change $this to Yii::app()->controller mainly) and eval all the php code so I can print it, but finally I got it and error page is user-friendly

You need to be careful because Yii::app()->controller may not be available all the time since this is evaluated in an error view.

well I use this for 404 error only and I have ‘catchAllRequest’ turned on, is it still dangerous?  ???

Yes, it is still dangerous because a 404 error may occur if user requests for an controller that does not exist.

Also, catchAllRequest is used when the site is in maintenance mode (that is, a maintenance page should be displayed for any request).

for all the n00bs (me), can you point us to where we can make simple HTML improvements to the default error view? I don’t want to add a complicated layout, just make some simple HTML changes to improve the style with my site logo and more user friendly content that links to the major site functions (eg. Home page, Search page.)

Thanks.

You can save your customized views to the protected/views/system directory.

http://www.yiiframework.com/doc/guide/topics.error

/Tommy

Doh, thanks Tommy, I’ve even seen that page before… ::)