Sorry guys did not know "errors always use the default layouts".

On Jul 18, 12:00 am, phpjoy <[EMAIL PROTECTED]> wrote:
> that's great to know, "errors always use the default layouts". :)
> didn't see it in the manual..
>
> thanks a tons for the solution.
>
> On Jul 16, 7:52 pm, rtconner <[EMAIL PROTECTED]> wrote:
>
> > Ah.. phpjoy, I had the same problem. There is no easy solution so far
> > as I could find. No good solution that I liked anyways. Errors always
> > use the default layout, and there is nothing you can do to change
> > that.
>
> > .. So.. the best solution as I could figure is this..
>
> > Create /app/error.php and copy and paste ErrorHandler into it. Then
> > modify it to read "class AppError extends ErrorHandler"
>
> > The modify the file to handle dynamic layouts. Here I'll make it easy
> > and just copy and past my (Cake 1.2) error.php file for you. Hope this
> > helps.
>
> > --------------------------------
> > <?php
>
> > /**
> >  * Override defaults cake error behavior
> >  */
> > class AppError extends ErrorHandler {
>
> >         var $layout = 'error';
>
> > /**
> >  * Displays an error page (e.g. 404 Not found).
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function error($params) {
> >                 extract($params);
> >                 $this->controller->base = $base;
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->viewPath='errors';
> >                 $this->controller->set(array('code' => $code,
> >                                                                             
> >     'name' => $name,
> >                                                                             
> >     'message' => $message,
> >                                                                             
> >     'title' => $code . ' ' . $name));
> >                 $this->controller->render('error404', $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Convenience method to display a 404 page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function error404($params) {
> >                 extract($params);
>
> >                 if (!isset($url)) {
> >                         $url = $action;
> >                 }
> >                 if (!isset($message)) {
> >                         $message = '';
> >                 }
> >                 if (!isset($base)) {
> >                         $base = '';
> >                 }
>
> >                 header("HTTP/1.0 404 Not Found");
> >                 $this->error(array('code' => '404',
> >                                                         'name' => 'Not 
> > found',
> >                                                         'message' => 
> > sprintf(__("The requested address %s was not found
> > on this server.", true), $url, $message),
> >                                                         'base' => $base));
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing Controller web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingController($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->base = $base;
> >                 $this->controller->webroot = $webroot;
> >                 $this->controller->viewPath ='errors';
> >                 $controllerName = str_replace('Controller', '', $className);
> >                 $this->controller->set(array('controller' => $className,
> >                                                                             
> >     'controllerName' => $controllerName,
> >                                                                             
> >     'title' => __('Missing Controller', true)));
> >                 $this->controller->render('missingController', 
> > $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing Action web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingAction($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->base = $base;
> >                 $this->controller->webroot = $webroot;
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->set(array('controller' => $className,
> >                                                                             
> >     'action' => $action,
> >                                                                             
> >     'title' => __('Missing Method in Controller', true)));
> >                 $this->controller->render('missingAction', $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Private Action web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function privateAction($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->base = $base;
> >                 $this->controller->webroot = $webroot;
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->set(array('controller' => $className,
> >                                                                             
> >     'action' => $action,
> >                                                                             
> >     'title' => __('Trying to access private method in class',
> > true)));
> >                 $this->controller->render('privateAction', $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing Table web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingTable($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->set(array('model' => $className,
> >                                                                             
> >     'table' => $table,
> >                                                                             
> >     'title' => __('Missing Database Table', true)));
> >                 $this->controller->render('missingTable', $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing Database web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingDatabase($params = array()) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->set(array('title' => __('Scaffold Missing
> > Database Connection', true)));
> >                 $this->controller->render('missingScaffolddb', 
> > $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing View web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingView($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->base = $base;
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->set(array('controller' => $className,
> >                                                                             
> >     'action' => $action,
> >                                                                             
> >     'file' => $file,
> >                                                                             
> >     'title' => __('Missing View', true)));
> >                 $this->controller->render('missingView', $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing Layout web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingLayout($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->base = $base;
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->layout = 'default';
> >                 $this->controller->set(array('file'  => $file,
> >                                                                             
> >     'title' => __('Missing Layout', true)));
> >                 $this->controller->render('missingLayout', $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Database Connection web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingConnection($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->set(array('model' => $className,
> >                                                                             
> >     'title' => __('Missing Database Connection', true)));
> >                 $this->controller->render('missingConnection', 
> > $this->layout);
> >                 exit();
> >         }
> > /**
> >  * Renders the Missing Helper file web page.
> >  *
> >  * @param array $params Parameters for controller
> >  * @access public
> >  */
> >         function missingHelperFile($params) {
> >                 extract(Router::getPaths());
> >                 extract($params, EXTR_OVERWRITE);
>
> >                 $this->controller->base = $base;
> >                 $this->controller->viewPath = 'errors';
> >                 $this->controller->webroot = $this->_webroot();
> >                 $this->controller->set(array('helperClass'
>
> ...
>
> read more >>


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to