Reputation: 739
I know that there are many questions and answeres to "Unable to render template" but my question has a twist.
When I open this URL: http://localhost:8080/users/usermanager/index
I get this error: Zend\View\Renderer\PhpRenderer::render: Unable to render template "users/user-manager/index"; resolver could not resolve to a file
Which is totally fine as I have renamed user-manager
to usermanager
. I have grepped my entire code and can not find any reference to user-manager
anymore. Why is Zend still searching for it?
My module.config.php:
<?php
namespace Users;
return array (
'controllers' => array (
'invokables' => array (
'Users\Controller\Index' => 'Users\Controller\IndexController',
'Users\Controller\Register' => 'Users\Controller\RegisterController',
'Users\Controller\Login' => 'Users\Controller\LoginController',
'Users\Controller\UserManager' => 'Users\Controller\UserManagerController'
)
),
'router' => array (
'routes' => array (
'users' => array (
'type' => 'Literal',
'options' => array (
'route' => '/users',
'defaults' => array (
'__NAMESPACE__' => 'Users\Controller',
'controller' => 'Index',
'action' => 'index'
)
),
'may_terminate' => true,
'child_routes' => array (
'default' => array (
'type' => 'Segment',
'options' => array (
'route' => '/[:controller[/:action]]',
'constraints' => array (
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
),
'defaults' => array ()
)
)
)
),
'usermanager' => array (
'type' => 'Segment',
'options' => array (
'route' => '/usermanager[/:action[/:id]]',
'constraints' => array (
'action' => '[a-zA-z][a-zA-z0-0_-]*',
'id' => '[a-zA-Z0-9_-]*'
),
'defaults' => array (
'controller' => 'Users\Controller\UserManager',
'action' => 'index'
)
)
)
)
),
'service_manager' => array (
'abstract_factories' => array (
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory'
),
'aliases' => array (
'translator' => 'MvcTranslator'
)
),
'translator' => array (
'translation_file_patterns' => array (
array (
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
'text_domain' => __NAMESPACE__
)
)
),
'view_manager' => array (
'template_path_stack' => array (
'users' => __DIR__ . '/../view'
)
)
);
Thanks for any help!
Upvotes: 0
Views: 815
Reputation: 2420
If you really want to use template names out of the naming convention you could create a template_map like so:
module.config.php
view_manager' => array(
...
'template_map' => array(
'users/user-manager/index' => __DIR__ . '/../view/users/user-manager/index.phtml',
...
I personally just stick with the convention since creating these map's is somewhat of a hassle.
Upvotes: 2
Reputation: 15656
I think you also have to change UserManager
to Usermanager
.
Zend2 automatically translate StrningsLikeThis
to strings-like-this
when it comes to search for default views.
Upvotes: 5