So I have the view file complete for a current project and now I’m implementing the ability for the user to email that view to someone else. I’d love to be able to reuse the code in this view file rather than copy/paste it in an email template. That just begs for problems down the road when the users want me to change a portion of the view (and it’s the antithesis of DRY).
How can I take a block of code and move it to a shared template file that both the email and view templates can use? I’ll still need to add some specific css to the email template, so just making the email refer to the view’s ctp file isn’t a good enough option.
If I were just coding my own php files (not using the cake framework), I would put a block of code in another file and use an include statement in both the view and email files. How should I do this in cakephp?
Thanks!
John
Check out elements:
http://book.cakephp.org/view/1081/Elements
They allow you to do exactly what you describe.
So you would create your element (shared code) and then use it in your email and view.