Part of the account registration process on my site involves the verification of the user's e-mail address. I'm confirming this in the traditional style of sending a generated 'activation key' to the users e-mail address and then requiring them to input it in to the site.
My web app will also be responsible for sending various other e-mails with dynamic content, and I'd very much like them to have the same style and layout.
So it makes sense to use the features of Zend_Layout and Zend_View for this, rendering the output and sending via Zend_Mail.
I've ran in to a few problems and got a little confused, makes me think im going about this the wrong way.
My initial attempt has been to create what I thought would be a unique instance of Zend_View, and setting the layout script to one which has inline CSS etc.
The following is a snippet from the action which handles account registration. The entire action is responsible for checking the provided information, creating the account, generating the mail body, sending the mail, then rendering a 'registration successful' style page to the browser
--
$view = new Zend_View;
$view->layout()->setLayout('email');
$view->setScriptPath(APP_PATH.'email');
$view->assign('token', $activation_key);
$m = new Zend_Mail;
$m->setBodyHtml($view->render('register.phtml'));
$m->send();
--
This would appear to work correctly as far as sending the actual HTML mail is concerned, however it seems my calls to $view->layout()->setLayout() have affected the layout being using for the actual controller action making the resulting 'registration successful' web page being tainted.
I hope this makes sense, I'm guessing that I can only have one instance of Zend_View and Zend_Layout. Resetting the layout script to the default after the mail is generated may be a solution but it leaves me to believe I may be going about this the wrong way.
In short, how can I render and capture a view script while making use of layouts without affecting those which have been linked to my controller/action.
Thanks in advance
My web app will also be responsible for sending various other e-mails with dynamic content, and I'd very much like them to have the same style and layout.
So it makes sense to use the features of Zend_Layout and Zend_View for this, rendering the output and sending via Zend_Mail.
I've ran in to a few problems and got a little confused, makes me think im going about this the wrong way.
My initial attempt has been to create what I thought would be a unique instance of Zend_View, and setting the layout script to one which has inline CSS etc.
The following is a snippet from the action which handles account registration. The entire action is responsible for checking the provided information, creating the account, generating the mail body, sending the mail, then rendering a 'registration successful' style page to the browser
--
$view = new Zend_View;
$view->layout()->setLayout('email');
$view->setScriptPath(APP_PATH.'email');
$view->assign('token', $activation_key);
$m = new Zend_Mail;
$m->setBodyHtml($view->render('register.phtml'));
$m->send();
--
This would appear to work correctly as far as sending the actual HTML mail is concerned, however it seems my calls to $view->layout()->setLayout() have affected the layout being using for the actual controller action making the resulting 'registration successful' web page being tainted.
I hope this makes sense, I'm guessing that I can only have one instance of Zend_View and Zend_Layout. Resetting the layout script to the default after the mail is generated may be a solution but it leaves me to believe I may be going about this the wrong way.
In short, how can I render and capture a view script while making use of layouts without affecting those which have been linked to my controller/action.
Thanks in advance
没有评论:
发表评论