@@ -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,34 +177,24 @@ 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 default template name resolver uses fully qualified controller
182+ class name, stripping only ` \Controller\ ` subnamespace, if present.
183+ For example, ` AwesomeMe\MyModule\Controller\HelloWorldController ` is resolved
184+ to template name ` awesome-me/my-module/hello-world ` .
185+
186+ For prior versions default was to strip subnamespaces but optional mapping rules
187+ allowed to whitelist namespaces in module configuration to enable current
188+ resolver behavior:
187189
188190``` php
189191'view_manager' => array(
190- // Controller namespace to template map
191- // or whitelisting for controller FQCN to template mapping
192192 'controller_map' => array(
193- '<Module \Name >' => true,
193+ '<AwesomeMe \MyModule >' => true,
194194 ),
195195),
196196```
197197
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- ```
207-
208198## Create a Route
209199
210200Now that we have a controller and a view script, we need to create a route to it.
0 commit comments