Renvoyer vers une page si une action ou controlleur n'existe pas
Bonjour,
Lorsque je tappe une url qui n'existe pas (ex: monsite/controlleur/nimportequoi) Zend me génère une exception de ce type :
Code:
Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::errdsqfAction() does not exist and was not trapped in __call()' in C:\wamp\www\mytranspole\library\zend\Controller\Action.php:480 Stack trace: #0 [internal function]: Zend_Controller_Action->__call('errdsqfAction', Array) #1 C:\wamp\www\mytranspole\library\zend\Controller\Action.php(497): IndexController->errdsqfAction() #2 C:\wamp\www\mytranspole\library\zend\Controller\Dispatcher\Standard.php(238): Zend_Controller_Action->dispatch('errdsqfAction') #3 C:\wamp\www\mytranspole\library\zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 C:\wamp\www\mytranspole\index.php(43): Zend_Controller_Front->dispatch() #5 {main} thrown in C:\wamp\www\mytranspole\library\zend\Controller\Action.php on line 480
Si dans mon fichier index.php, je remplace
Code:
$frontController->throwExceptions(true);
par
Code:
$frontController->throwExceptions(false);
j'obtiens
Code:
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in C:\wamp\www\mytranspole\library\zend\Controller\Dispatcher\Standard.php:194 Stack trace: #0 C:\wamp\www\mytranspole\library\zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\wamp\www\mytranspole\index.php(43): Zend_Controller_Front->dispatch() #2 {main} thrown in C:\wamp\www\mytranspole\library\zend\Controller\Dispatcher\Standard.php on line 194
1. La ligne : "$frontController->throwExceptions(false);" n'est pas censé ne plus afficher d'exceptions ? Apparement non, mais comment faire pour ne plus les avoir ?
2. Je souhaiterai que lorsque le controlleur ou l'action n'existe pas, j'ai une redirection vers une page type "erreur 404 page non trouvé" ou bien vers la page principal du site. C'est possible ?
3. Ou est indiqué dans le fichier principal index.php que le fichier index à ouvrir par défaut est bien /monsite/Index ? Je suis mon premier tutorial (qui fonctionne) mais je ne vois pas ou est indiquer que par défaut il faut ouvrir index/ comme Controlleur. Est-il possible d'indiquer un autre Controlleur par défaut en guise de page d'accueil ? Voici le code que je pense être chargé d'afficher le controlleur par défaut index :
Code:
1 2 3 4 5 6 7
| // setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true); //-- Contrôleur primaire lance les exceptions
$frontController->setControllerDirectory('./application/controllers'); //-- Répertoires ou se trouvent le controlleur
// run!
$frontController->dispatch(); |
Ca fait plein de question, excusez moi, mais je suis vraiment vraiment débutant zend. merci