2014-02-14 3 views
0

"템플릿을 렌더링 할 수 없습니다."라는 질문과 답변이 많지만 제 질문에 이상이 있습니다. 내가 URL을 열 때젠드 프레임 워크 2 : 템플릿을 렌더링 할 수 없습니다. -

: 나는이 usermanageruser-manager 이름을 바꾼로 완전히 괜찮 Zend\View\Renderer\PhpRenderer::render: Unable to render template "users/user-manager/index"; resolver could not resolve to a file

: http://localhost:8080/users/usermanager/index

을 나는이 오류가 발생합니다. 내 전체 코드를 덮어 더 이상 user-manager에 대한 참조를 찾을 수 없습니다. 젠드가 왜 아직도 그것을 찾고 있습니까?

내 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' 
       ) 
     ) 
); 

감사합니다!

답변

5

UserManagerUsermanager으로 변경해야한다고 생각합니다.

Zend2는 기본보기를 검색 할 때 StrningsLikeThisstrings-like-this으로 자동 변환합니다.

+3

+1. 또는보기 폴더를'user-manager'로 유지하십시오. –

+0

감사! 나는 내 자신으로 이것을 결코 발견하지 못했을 것이다. – AlexWerz

2

당신이 정말로 명명 규칙에서 템플릿 이름을 사용하려면 당신이 그렇게 같은 template_map을 만들 수 있습니다

module.config.php

view_manager' => array(
    ... 
    'template_map' => array(
     'users/user-manager/index' => __DIR__ . '/../view/users/user-manager/index.phtml', 
    ... 

나는 개인적으로 그냥이지도의를 생성하기 때문에 규칙을 고수은 다소이다 혼전.

+0

Template_map의 성능이 훨씬 뛰어나므로이를 사용하는 것이 좋습니다. Composer 나'zendframework/bin'을 사용한다면'vendor/bin'을보세요. – jmleroux