Parse Template |
[eluser]rpe[/eluser]
Hey... i have a question about parse template class Can anyone help me if i write somecode like "{code}" .....tag {code} , it can call view like $this->load->view(nameofview). I have been read documentation on code igniter but tag {code} just can replace with container example $data['hello']='hello world' $data['code']='it s me' $this->parse->parse('template',$data) ---------------------- <html> <body> {hello} {code} </body> </html> but i want to replace "{code}" that i can include some another view in the root view Thank you
[eluser]renownedmedia[/eluser]
Get the view file you want to place where {code} is by doing something like this: $string = $this->load->view('myfile', '', true); Then replace code with what you want it to be: $string2 = str_replace('{code}', $data['code'], $string); Then finally spit it out to the screen
[eluser]davidbehler[/eluser]
If you have many variable that need to be replace, you might try this: Code: $string = $this->load->view(‘myfile’, ‘’, true);
[eluser]Phil Sturgeon[/eluser]
Surely you could just do this: Code: $data['hello']='hello world';
[eluser]dezafu[/eluser]
how if i want to parse class and view to that template
[eluser]Phil Sturgeon[/eluser]
Code: $data['hello']='hello world'; Come on dude, read the manual! :-)
[eluser]Phil Sturgeon[/eluser]
[quote author="dezafu" date="1249565201"]that just template... see http://ellislab.com/forums/viewreply/620213/[/quote] The reply in that post is suggesting the exact same thing as me.
[eluser]Phil Sturgeon[/eluser]
Do you mean you want to parse the 'viewfile' but not the main template? If so: Code: $data['hello']='hello world'; Want me to chew for you as well?! :-p
[eluser]dezafu[/eluser]
No.. parse the view... but i want to parse the controller... not only view but with controller... |
Welcome Guest, Not a member yet? Register Sign In |