Welcome Guest, Not a member yet? Register   Sign In
Can you load data into a view, then parse it?
#1

[eluser]Braden Schaeffer[/eluser]
########
Sorry... wrong forum (kind of)
########


Having some trouble trying to figure this out. Let's say you have something like this stored in a database:
Code:
<h1>{Title}</h1>
<p>{Content}</p>

How would you go about loading that string from the database into another view file, then parsing that view file?

This is not the method I am using to deliver html to my view files, I just want to know how to do this (or if you even can). I've been trying for a while off and on and I can't seem to figure out how to get it to work.

Any suggestions? I'd really appreciate any help you could pass on!

Thanks in advance!
#2

[eluser]firefly_HIT[/eluser]
first,get the source html code stored in your datebase ,and put it in a variable as a string,
then post to your view file in proper place via a controller, i am sure it can be ok.

i have test in my controller

function index()
{
echo "<h1>test</h1>";
}

it works ,not show""<h1>test</h1>“, just echo the "test" in the page,

indeed ,what your have done in the process is that: edit the sorcecode of the last html page with php,prase the code is your ie's work.
#3

[eluser]ggoforth[/eluser]
Hi Braden,

I would imagine what your asking for to look something like this:

Code:
function index(){
    //load the info from the db into a variable
    $my_str = $this->db->select->.....->get()->row()->field_name;
    
    //replace the {Title} with another value
    $title = "This is my title";
    $new_str = str_replace("{Title}",$title,$my_str);

    echo $new_str;//Yields <h1>This is my title</h1>
}

Is that what you were asking for?

Greg




Theme © iAndrew 2016 - Forum software by © MyBB