Welcome Guest, Not a member yet? Register   Sign In
Writing views from stored HTML??
#1

[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?
#2

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

[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.
#4

[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);




Theme © iAndrew 2016 - Forum software by © MyBB