goalio / GoalioForgotPassword

A Zend Framework 2 (ZF2) Module offering forgot password via e-mail functionality to ZfcUser
BSD 3-Clause "New" or "Revised" License
42 stars 49 forks source link

Custom template paths #44

Closed antonioolmedo closed 9 years ago

antonioolmedo commented 9 years ago

How I can override those params?:

'view_manager' => array( 'template_path_stack' => array( 'goalioforgotpassword' => DIR . '/../view', ), 'template_map' => array( 'zfc-user/user/login' => DIR . '/../view/zfc-user/user/login.phtml', ), ),

I need to change those variables to look for my own templates.

I read this issue https://github.com/goalio/GoalioForgotPassword/issues/13 but I can't find the solution for me, I thought implement my own controller using your service but I want to know if there are any other solution.

Thanks, Antonio.

antonioolmedo commented 9 years ago

I found this method, you need to add these lines at yout module.config into the "view_manager/template_map" array:

'goalio-forgot-password/forgot/forgot' => DIR . '/../view/goalio-forgot-password/forgot/forgot.phtml', 'goalio-forgot-password/forgot/sent' => DIR . '/../view/goalio-forgot->password/forgot/sent.phtml', 'goalio-forgot-password/forgot/passwordchanged' => DIR . '/../view/goalio-forgot-password/forgot/passwordchanged.phtml', 'goalio-forgot-password/forgot/reset' => DIR . '/../view/goalio-forgot-password/forgot/reset.phtml'

stefankleff commented 9 years ago

You should make yourself familiar how zend framework applications and the template resolver are configured in general: http://framework.zend.com/manual/current/en/modules/zend.mvc.intro.html#basic-application-structure http://framework.zend.com/manual/current/en/modules/zend.view.quick-start.html

In short the template name is (usually) generated from the namespace, controller and action. There are two resolvers in zf2: the map and the path stack. First the renderer looks in the map if the name could be found, otherwise the path stack is used. This is why you could add the lines as described above. But you should place your config in the config/autload dir instead of changing module configurations.