phpzend-framework2zend-framework-mvczend-framework-modules

Make Zend 2 to only search for templates in same Module


I have (simplified) two modules, Application and Admin. I have worked on the Admin module for a while now and started with Application. Both the modules feature a controller named UsersController.

Now as I started to make the Application and created some routes and actions, my Admin module broke. The error I got when trying to open any admin page everywhere was similar to

Unable to render template "application/users/index"

According to the docs, the first part of the template path is taken from the namespace of the calling controller. But ever since I created the directory module/Application/view/application/users/, it tries to take all the Admin\Controller\UsersController templates from there, without regard to the namespace.

How can I make Zend to use the namespace again, without having to force the template file in the action every time?

(Using Zend 2.1.3)


Solution

  • The problem here was that I used the same aliases for Controller names in more than one module. So I changed their names like this:

    'controllers' => array(
        'invokables' => array(
            'AdminIndex' => 'Admin\Controller\IndexController',
        ),
    ),
    

    The other module config used the same names and thus just overrode the ones from my Admin module.