Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting an error template #5

Closed
levybee opened this issue Jan 17, 2013 · 3 comments
Closed

Getting an error template #5

levybee opened this issue Jan 17, 2013 · 3 comments

Comments

@levybee
Copy link

levybee commented Jan 17, 2013

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

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

@maxnuf
Copy link
Owner

maxnuf commented Jan 18, 2013

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.

@levybee
Copy link
Author

levybee commented Jan 21, 2013

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

#0 D:\xampp\php\custom_libs\Zend\ServiceManager\AbstractPluginManager.php(110): Zend\ServiceManager\ServiceManager->get('Application\Con...', false)
#1 D:\xampp\php\custom_libs\Zend\Mvc\Controller\ControllerManager.php(114): Zend\ServiceManager\AbstractPluginManager->get('Application\Con...', Array, false)
#2 D:\xampp\php\custom_libs\Zend\Mvc\DispatchListener.php(90): Zend\Mvc\Controller\ControllerManager->get('Application\Con...')
#3 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#4 D:\xampp\php\custom_libs\Zend\EventManager\EventManager.php(464): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#5 D:\xampp\php\custom_libs\Zend\EventManager\EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#6 D:\xampp\php\custom_libs\Zend\Mvc\Application.php(297): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#7 F:\EWT WORKS...........


Below is IndexController.php if it would be of any help:

@maxnuf
Copy link
Owner

maxnuf commented Jan 21, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants