![]() |
RESOLVED: include() Heredoc in Controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: RESOLVED: include() Heredoc in Controller (/showthread.php?tid=42556) |
RESOLVED: include() Heredoc in Controller - El Forum - 06-10-2011 [eluser]tkaw220[/eluser] Hi, I ran into below situation, and hopefully I could get some helps here. I have a controller to send out newsletter. I used PHP heredoc to avoid the need to escape string: Code: class Newsletter extends CI_Controller { 1) My first headache: I dislike the indentation of my controller (at the end of the delimiter), how could I make the line indent consistent? 2) Is it possible to exclude the HTML newsletter (the HTML code) from my controller and include it by using PHP include() before calling the CI send email class? For example: Code: private function _get_file() I include the external markup before the send mail function, but the outcome is an empty email. I tried to describe my issue as detail as I can. Hopefully I could get some help here. Thank you. Regards, Edwin RESOLVED: include() Heredoc in Controller - El Forum - 06-10-2011 [eluser]CroNiX[/eluser] Why not store your email html content as a view? Then just use the third parameter to return the view as a variable instead of outputting it to the browser? View: email_view.php Code: <!DOCTYPE HTML> Then in your controller: Code: public function send($title, $content) RESOLVED: include() Heredoc in Controller - El Forum - 06-11-2011 [eluser]tkaw220[/eluser] Hi CroNix, Your codes work perfectly. Thank you very much. Now my controller is clean and neat. Have a nice weekend. Regards, Edwin |