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

How do I override the forgot password email template? #13

Closed personman closed 10 years ago

personman commented 11 years ago

Is there a way to override the email template, replacing it with my own? If not, I can add that to the ForgotOptionsInterface and do a PR.

pdobrigkeit commented 11 years ago

Hey, try to add the following to your config file

'view_manager' => array(
    'template_map' => array(
        'goalio-forgot-password/email/forgot' => __DIR__ . '/../my/path/to/the/template/email.phtml',
    ),
),

if that does not work please do the PR and I saw that there is a typo in the module.config.php it probably should be goalio-forgot-password there...

personman commented 11 years ago

Ah, I was hoping there was a way to do this. I'm digging into the template map now to see if I can get this to work for me. You see, I'm using this forgot password module to also handle the email sent to the new users created when a college subscribes in my app. When subscription is complete, I create the user accounts and send them an email with a link that they can use to do an initial login and set their password. So, I want to be able to switch templates at runtime in this case, while still using another template for actual password reset requests. I'm trying to learn how to take your suggestion and turn it into something that I change from a controller, rather than in the config file.

pdobrigkeit commented 11 years ago

Well in that case the template-map will not be very helpful... But why don't you try to supply your own implementation of 'goalioforgotpassword_password_service'? You could extend from the existing service and provide new functions like sendSignupCompleteMessage... That would be the direction I would be thinking of.

Also maybe you should take a look at https://github.com/cdli/CdliTwoStageSignup... It might be already offering what you want to achieve?

personman commented 11 years ago

I wasn't able to find a good way to alter the template map on the fly (so that just one controller action could use a different template), so I went ahead and added a config option for the email template in this PR: https://github.com/goalio/GoalioForgotPassword/pull/14

I considered just extending the password service as you suggested, but I didn't really want to change any functionality except the email subject, which already has a config option, and the template. If you agree that an option for the template is a useful feature for the module, then that will make it work for my purposes.

I did take a look at the two stage signup module you linked, but it doesn't quite do what I'm looking for and it doesn't seem as stable as this module. Thanks for your help on this!