Closed levybee closed 11 years ago
I don't think I can figure out what caused the error to occur..
But I can point out a few things that might help. First, you're still able to use the phprenderer (if you want to), so you could still let the error page be rendered by the phprenderer. In that case, just set the extension of your 404 page to "phtml". Smarty is only going to look for "tpl" files. If it cannot find one, some other rendering strategy will take over.
If you want all your templates to be in Smarty, than you have to write your 404.tpl in smarty syntax as well. I'm assuming you just copied 404.phtml from zendskeleton to 404.tpl, which means smarty will just output it's content as html.
Also you don't need to explicitly say you want to use the smartyViewStrategy as strategy in every module you're using. This is already done when you add 'MaxnufSmarty' to application.config.php
hope this helps.
Hi, I was able to get the error messages displayed in the 404.tpl. Here is the 404 error page:
A 404 error occurred Page not found. 1
Controller: resolves to invalid controller class or alias: Application\Controller\Application ; Exception:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for Application\Controller\Application Stack trace
Below is IndexController.php if it would be of any help:
<?php /**
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController { public function indexAction() { return new ViewModel(); } }
I hope that's a lot more clear, thank you.
good that you got the error page working.
Looking at the provided error, it seems you have done something wrong in your module/Application/config/module.config.php file It's looking for the class (or alias) 'Application\Controller\Application' which does not exist.
so either, you did something wrong with your route, or with the alias 'Application\Controller\Application', or you simply just need to create the ApplicationController.php file
Are you using the skeleton application? https://github.com/zendframework/ZendSkeletonApplication look at the module/Application/config/module.config.php file.
what you should have is something like:
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Application' => 'Application\Controller\ApplicationController'
),
),
But since it can't find 'Application', it seems you have your route point to 'Application' while it should point to 'Index', or something.
I don't think your issue is related to smarty.
Hi ,
First of all thank you for this module, have been searching all week for smarty to zf2 integration and this module comes very close to completing my task. Its just that I am getting a 404 page template instead of the index template and have no idea why. Here is the page that i get:
A 404 error occurred message ?> reason) && $this->reason): ?> reason) { case 'error-controller-cannot-dispatch': $reasonMessage = 'The requested controller was unable to dispatch the request.'; break; case 'error-controller-not-found': $reasonMessage = 'The requested controller could not be mapped to an existing controller class.'; break; case 'error-controller-invalid': $reasonMessage = 'The requested controller was not dispatchable.'; break; case 'error-router-no-match': $reasonMessage = 'The requested URL could not be matched by routing.'; break; default: $reasonMessage = 'We cannot determine at this time why a 404 was generated.'; break; } ?>
controller) && $this->controller): ?>
Controller: escape($this->controller) ?> controller_class) && $this->controller_class && $this->controller_class != $this->controller ) { echo " (resolves to " . $this->escape($this->controller_class) . ")"; } ?> exception) && $this->exception): ?> Exception:
escape($this->exception->getMessage()) ?> Stack trace
exception->getTraceAsString() ?>
....and below is the 404 template code:
A 404 error occurred
message ?>
<?php if (isset($this->reason) && $this->reason): ?>
<?php $reasonMessage= ''; switch ($this->reason) { case 'error-controller-cannot-dispatch': $reasonMessage = 'The requested controller was unable to dispatch the request.'; break; case 'error-controller-not-found': $reasonMessage = 'The requested controller could not be mapped to an existing controller class.'; break; case 'error-controller-invalid': $reasonMessage = 'The requested controller was not dispatchable.'; break; case 'error-router-no-match': $reasonMessage = 'The requested URL could not be matched by routing.'; break; default: $reasonMessage = 'We cannot determine at this time why a 404 was generated.'; break; } ?>
<?php endif ?>
<?php if (isset($this->controller) && $this->controller): ?>
Exception:
escape($this->exception->getMessage()) ?>
Stack trace
...and my view manager part in module.config.php ................. 'view_manager' => array( 'strategies' => array( 'SmartyViewStrategy' ), 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'layout/layout' => **DIR** . '/../view/layout/layout.tpl', 'application/index/index' => **DIR** . '/../view/application/index/index.tpl', 'error/404' => **DIR** . '/../view/error/404.tpl', 'error/index' => **DIR** . '/../view/error/index.tpl', ), 'template_path_stack' => array( 'application' => **DIR** . '/../view', ), ), .................. Thank you, Levy