Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zf2 resolve module view path

Starting from the skeleton application using beta3 how would you resolve the view path for a new module called Foo?

I have added below to the di config and now both modules action's render Foo's views.

'Zend\View\Resolver\TemplatePathStack' => array(
    'parameters' => array(
        'paths'  => array(
            'foo' => __DIR__ . '/../view',
        ),
    ),
),

I would expect Application\Controller\IndexController::indexAction() to render the views in Application and for Foo\Controller\IndexController::indexAction() to render Foo's views.

like image 679
gawpertron Avatar asked Feb 20 '23 18:02

gawpertron


1 Answers

Note that questions like this help shape the direction of the stable framework. :)

One idea I've been toying with is to use the module as part of the view script resolution. Right now, the default used is "/"; my proposal is to use "//", as this would help prevent naming conflicts between modules; it also makes it much simpler to understand exactly what view script you are overriding if you use template maps.

You can use this approach today, but it will require manually setting the template on the view models you return from your controllers.

like image 76
weierophinney Avatar answered Feb 27 '23 11:02

weierophinney