YesIAm
(Gergs Forex)
April 30, 2016, 2:41pm
1
I am using basic template but have adapted the advanced user password reset functionality, for some reason I can’t get it to find the mail layouts.
So in \mail\layouts I have
In web.php I have
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => 'app\mail\layouts',
...
The advanced template uses
'viewPath' => '@common/mail',
But as i’m using basic template, its not in the common/mail folder.
In sendMail function in PasswordResetRequestForm.php i have
return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])
...
However getting error
The view file does not exist: app\mail\layouts\passwordResetToken-html.php
I know this is going to be something small but for the life of me i cannot see it
YesIAm
(Gergs Forex)
May 2, 2016, 12:16pm
2
Any help please on how to set the viewpath ?
olegl84
(Oleg)
May 2, 2016, 1:19pm
3
It should be
'viewPath' => '@app\mail\layouts',
@app - is an alias to your "root" folder, you can check exact folder in config in "aliases" section
If you put path without @, Yii just search an ‘app’ folder which obviously not exists, more over it searches in folder where index.php resides
YesIAm
(Gergs Forex)
May 3, 2016, 10:29am
4
thanks , but i tried that and its giving me error
Invalid Parameter – yii\base\InvalidParamException
Invalid path alias: @app\mail\layouts
YesIAm
(Gergs Forex)
May 3, 2016, 10:40am
5
i moved the view files up a level to /mail and then i get bizarre location error of:
The view file does not exist: C:\wamp\www\mysite/mail\passwordResetToken-html.php
Thats using
'viewPath' => '@app/mail',
YesIAm
(Gergs Forex)
May 5, 2016, 12:09pm
6
must be something else i’m missing/doing wrong ?
softark
(Softark)
May 5, 2016, 1:41pm
7
Where exactly is your passwordResetToken-html.php located now?
Is it in "C:\wamp\www\mysite\mail"?
And I’m wondering what do you do with the layouts.
The original app-advanced template uses the following views and layouts.
@common
/mail
passwordResetToken-html.php
passwordResetToken-text.php
/layouts
html.php
text.php
YesIAm
(Gergs Forex)
May 8, 2016, 4:16am
8
It is located exactly in
C:\wamp\www\mysite\mail\layouts
I have tried it also at
C:\wamp\www\mysite\mail
So, currently this does not work
'viewPath' => '@app/mail/layouts',
Yes, the app-advanced in @common was working when I initially created my app using the advanced template. So adapting it to basic and locating it correctly is the problem
Any suggestions ?
softark
(Softark)
May 8, 2016, 7:28am
9
If you have transplanted the views for mail from app-advanced to app-basic without much modification, then your @app /mail directory should be like this:
@app
/mail
passwordResetToken-html.php
passwordResetToken-text.php
/layouts
html.php
text.php
I mean, @app /mail should contain "passwordResetToken-html.ph" and "passwordResetToken-text.php", and @app /mail/layouts should contain "html.php" and "text.php".
And your config should be
'viewPath' => '@app/mail',
YesIAm
(Gergs Forex)
May 8, 2016, 11:55am
10
Thank you !
Finally !
What i had missed was the actual /layouts/html.php and text.php files when i copied the others across !
So simple