@@ -146,7 +146,7 @@ So, what are we doing here?
146146
147147We return a ` ViewModel ` . The view layer will use this when rendering the view,
148148pulling variables and the template name from it. By default, you can omit the
149- template name, and it will resolve to "lowercase-controller-name/lowercase-action-name".
149+ template name, and it will resolve to "lowercase-module-name/lowercase- controller-name/lowercase-action-name".
150150However, you can override this to specify something different by calling
151151` setTemplate() ` on the ` ViewModel ` instance. Typically, templates will resolve
152152to files with a ".phtml" suffix in your module's ` view ` directory.
@@ -177,33 +177,25 @@ That's it. Save the file.
177177## View scripts for module names with subnamespaces
178178
179179As per PSR-0, modules should be named following the rule: ` <Vendor Name>\<Namespace>\* ` .
180- However, the default controller class to template mapping does not work very
181- well with those: it will remove subnamespace.
182180
183- To address that issue, new mapping rules were introduced with version 2.3.0. To
184- maintain backwards compatibility, that mapping is not enabled by default. To
185- enable it, you need to add your module namespace to a whitelist in your module
186- configuration:
181+ Since version 3.0, the default template name resolver uses fully qualified
182+ controller class names, stripping only the ` \Controller\\ ` subnamespace, if
183+ present. For example, ` AwesomeMe\MyModule\Controller\HelloWorldController `
184+ resolves to the template name ` awesome-me/my-module/hello-world ` via the
185+ following configuration:
187186
188187``` php
189188'view_manager' => array(
190- // Controller namespace to template map
191- // or whitelisting for controller FQCN to template mapping
192189 'controller_map' => array(
193- '< Module \Name > ' => true,
190+ 'AwesomeMe\MyModule ' => true,
194191 ),
195192),
196193```
197194
198- Once you have, you can create the directory ` view/<module>/<name>/hello ` . Inside
199- that directory, create a file named ` world.phtml ` . Inside that, paste the
200- following:
201-
202- ``` php
203- <h1 >Greetings!</h1 >
204-
205- <p >You said "<?php echo $this->escapeHtml($message) ?>".</p >
206- ```
195+ (In v2 releases, the default was to strip subnamespaces, but optional mapping rules
196+ allowed whitelisting namespaces in module configuration to enable current
197+ resolver behavior. See the [ migration guide] ( migration/to-v3-0.md#zendmvcviewinjecttemplatelistener )
198+ for more details.)
207199
208200## Create a Route
209201
0 commit comments