Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Templatemap generator: keys of templatemap not correct? #4612

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

Templatemap generator: keys of templatemap not correct? #4612

tranba opened this issue Jun 8, 2013 · 9 comments
Assignees
Labels
Milestone

Comments

@tranba
Copy link

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"

@weierophinney
Copy link
Member

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
Copy link
Author

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"

@weierophinney
Copy link
Member

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
Copy link
Author

tranba commented Jun 14, 2013

Thanks!

@ThaDafinser
Copy link
Contributor

@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:
#4834
#4835

@ThaDafinser
Copy link
Contributor

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

@Maks3w
Copy link
Member

Maks3w commented Jul 15, 2013

Choosing between #4834 and #4835 I preffer #4834

@ThaDafinser
Copy link
Contributor

Maybe #4834 for 2.2.2 and the other for 2.3.0?

@Maks3w
Copy link
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants