![]() |
Parse Template - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Parse Template (/showthread.php?tid=21262) Pages:
1
2
|
Parse Template - El Forum - 08-04-2009 [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 Parse Template - El Forum - 08-04-2009 [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 Parse Template - El Forum - 08-05-2009 [eluser]davidbehler[/eluser] If you have many variable that need to be replace, you might try this: Code: $string = $this->load->view(‘myfile’, ‘’, true); Parse Template - El Forum - 08-05-2009 [eluser]Phil Sturgeon[/eluser] Surely you could just do this: Code: $data['hello']='hello world'; Parse Template - El Forum - 08-05-2009 [eluser]dezafu[/eluser] how if i want to parse class and view to that template Parse Template - El Forum - 08-06-2009 [eluser]Phil Sturgeon[/eluser] Code: $data['hello']='hello world'; Come on dude, read the manual! :-) Parse Template - El Forum - 08-06-2009 [eluser]dezafu[/eluser] that just template... see http://ellislab.com/forums/viewreply/620213/ Parse Template - El Forum - 08-06-2009 [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. Parse Template - El Forum - 08-06-2009 [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 Parse Template - El Forum - 08-06-2009 [eluser]dezafu[/eluser] No.. parse the view... but i want to parse the controller... not only view but with controller... |