ZF2-214: TemplatePathStack::resolve - view script path not chosen correctly

Issue Type: Bug Created: 2012-03-12T05:42:47.000+0000 Last Updated: 2012-03-12T13:35:31.000+0000 Status: Resolved Fix version(s): Reporter: Ja De (jade) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend\View

Related issues: Attachments:


use case:

  • 2 existing modules, both have a 'view' folder inside the 'src' folder
  • both modules have a controller 'IndexController' and action 'index'
  • different routes to each IndexController::indexAction exist
  • the module specific view path is added via module.config.php of its module to TemplatePathStack


  • TemplatePathStack::resolve does choose the first view path where a /index/index.phtml is found

So the order of paths in TemplatePathStack (result of config merging) determines the chosen view script.

involved code (in my case):

PhpRenderer::render downto PhpRenderer::resolver downto AggregateResolver::resolve downto TemplatePathStack::resolve

What should happen imho, is that the routeMatch controller namespace defines the view script path somehow.

Thank you for having a look at this.

Best regards, Jade


Posted by Matthew Weier O'Phinney (matthew) on 2012-03-12T13:35:20.000+0000

It's actually operating exactly as designed; order of registration does matter.

That said, we're planning to alter how the view resolution works for beta4 so that the template name includes the module name. This will mean, however, pushing view templates down one more level in the view directory:

<pre class="highlight">

I'm closing this as "not an issue", as the TemplatePathStack is working as intended. However, if you want to open an issue indicating the desired behavior against the Zend\View or Zend\Mvc component, please do so; that said, it's already designated for beta4.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.