将控制器视图用于电子邮件视图 CakePHP 2
Use controller view for email view CakePHP 2
将控制器操作的视图用作电子邮件模板的好方法是什么?目前有两个独立的视图:一个在 ../View/Emails/html/example.ctp
中,一个在 ../View/Example/example.ctp
中。这太湿了,让我头疼。
问。什么是最好的方法来解决这个问题并为两者使用相同的模板?
Controller
有一个 render
方法,您可以显式调用
http://book.cakephp.org/2.0/en/controllers.html#rendering-a-specific-view
并传递 ../path/to/email/template
或者你可以提取一个公共元素:
http://book.cakephp.org/2.0/en/views.html#elements
将控制器操作的视图用作电子邮件模板的好方法是什么?目前有两个独立的视图:一个在 ../View/Emails/html/example.ctp
中,一个在 ../View/Example/example.ctp
中。这太湿了,让我头疼。
问。什么是最好的方法来解决这个问题并为两者使用相同的模板?
Controller
有一个 render
方法,您可以显式调用
http://book.cakephp.org/2.0/en/controllers.html#rendering-a-specific-view
并传递 ../path/to/email/template
或者你可以提取一个公共元素: http://book.cakephp.org/2.0/en/views.html#elements