CodeIgniter Forums
Writing views from stored HTML?? - 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: Writing views from stored HTML?? (/showthread.php?tid=42709)



Writing views from stored HTML?? - El Forum - 06-16-2011

[eluser]rvent[/eluser]
Hello,

Is it possible to store HTML code in a database, then have CI pull the content and write it to a view file in the "views" folder?


Writing views from stored HTML?? - El Forum - 06-16-2011

[eluser]marcogmonteiro[/eluser]
Yes, i don't see a problem with that.


Writing views from stored HTML?? - El Forum - 06-18-2011

[eluser]Nick_MyShuitings[/eluser]
Why would you have it write it to a view file? What would be the flow there, and what benefit of making a system write command out of database data (SCARY SECURITY ISSUES THERE)? You could just parse it for contained vars and then pass it to an existing view file that would do nothing but echo it.


Writing views from stored HTML?? - El Forum - 06-18-2011

[eluser]fedeisas[/eluser]
Yes, you can.

I've used this flow when building a newsletter system.

You can load views inside a $var just like this:
Code:
$string = $this->load->view('myfile', '', true);


Then you can parse that $string with some data:
Quote:$this->load->library('parser');

$data = array(
'blog_title' => 'My Blog Title',
'blog_heading' => 'My Blog Heading'
);

$this->parser->parse_string($string, $data);