Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Templatemap generator: keys of templatemap not correct? #4612

Closed
tranba opened this Issue Jun 8, 2013 · 9 comments

Comments

Projects
None yet
4 participants

tranba commented Jun 8, 2013

When i using templatemap_generator to create template file map for my module, ex for Album module:

<?php
// Generated by ZF2's ./bin/templatemap_generator.php
return array(
    'view/album/album/add'    => __DIR__ . '/view/album/album/add.phtml',
    'view/album/album/delete' => __DIR__ . '/view/album/album/delete.phtml',
    'view/album/album/edit'   => __DIR__ . '/view/album/album/edit.phtml',
    'view/album/album/index'  => __DIR__ . '/view/album/album/index.phtml',
);

If I using this file in my application and access to index page I will received error:
Zend\View\Renderer\PhpRenderer::render: Unable to render template "album/album/index".
Problem is PhpRenderer load "album/album/index" template, not "view/album/album/index"

Owner

weierophinney commented Jun 10, 2013

Where are you placing the generated template map file?

Based on what it generated, it should be in the root of your module, and you should likely include it from your configuration. Otherwise, you'll have to change the paths manually to reflect the current location, as __DIR__ indicates the directory in which the file with the template map sits.

tranba commented Jun 12, 2013

@weierophinney please view my example here https://github.com/tranba/TestApp
The generated template map sit in the root of ZendSkeletonModule module, I include it in module.config.php file.
When access /module-specific-root/skeleton/foo it show "Zend\View\Renderer\PhpRenderer::render: Unable to render template "zend-skeleton-module/skeleton/foo"; resolver could not resolve to a file"

Owner

weierophinney commented Jun 13, 2013

I see the problem with the template map -- the keys should not include "view/" in them.

I tried this on a module of my own, and had the same results -- "view/" was prefixed to all keys. To get it to work, I did the following:

  • Descended into my view directory
  • Executed php /path/to/templatemap_generator.php -v . -o ../template_map.php

This generated the template map correctly.

So, use that as a workaround until we get a fix for the script.

@ghost ghost assigned weierophinney Jun 13, 2013

tranba commented Jun 14, 2013

Thanks!

Contributor

ThaDafinser commented Jul 15, 2013

@weierophinney @tranba i just created two pull requests to fix this in different ways

One time to do it with the parameter "--useViewPath", or one with the direct fix:
zendframework#4834
zendframework#4835

Contributor

ThaDafinser commented Jul 15, 2013

Please keep in mind that the second might be a BC break, if someone already used the alias with the "view" prefix....

Member

Maks3w commented Jul 15, 2013

Choosing between #4834 and #4835 I preffer #4834

Contributor

ThaDafinser commented Jul 16, 2013

Maybe #4834 for 2.2.2 and the other for 2.3.0?

Member

Maks3w commented Jul 16, 2013

IMO, the way of generate the classmap should be simple and agnostic to the framework internals. For that reason #4834 offer the switch for enable or disable zf2 specific needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment