calling an Error 404 page from within the Controller
Hi, I was wondering, what is the correct way to call a 404 Error from wihtin a controller? The situation is this: I use pretty urls (for SEO) to let the user navigate through my site. When the controller is called to show an appartment, 4 parameters are passed. The first thing I do is check that the parameters have been passed and that a certain one is numeric (the id). Currently I'm using this: if(!is_numeric($id)) { $this-redirect('/'); exit(); } but I'm looking for a (clean) way to redirect to the error page. Any help is appreciated! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: calling an Error 404 page from within the Controller
I use something like this (cake 1.2 prebeta): $this-cakeError('error404',array(array('url'='/'))); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: calling an Error 404 page from within the Controller
Thanks snowdog... which class offers cakeError as a method? I couldn't find this in the API. Another question... is it possible to set a custom layout for the error404.thtml file? On 11 dec, 10:58, snowdog [EMAIL PROTECTED] wrote: I use something like this (cake 1.2 prebeta): $this-cakeError('error404',array(array('url'='/'))); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: calling an Error 404 page from within the Controller
If You create a custom 404 layout, take care that an 404 code by HTTP is provided. This can be done by header(http/1.0 404 not found); To prevent errors you can use something like this: if(!headers_sent) { header(http/1.0 404 not found); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: calling an Error 404 page from within the Controller
But how do I define the layout that CakePHP should use for the template error404.thtml On 11 dec, 12:37, powtac [EMAIL PROTECTED] wrote: If You create a custom 404 layout, take care that an 404 code by HTTP is provided. This can be done by header(http/1.0 404 not found); To prevent errors you can use something like this: if(!headers_sent) { header(http/1.0 404 not found); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---