![]() |
How can I want pass a string with the view content instead of a file name when loading a view? - 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: How can I want pass a string with the view content instead of a file name when loading a view? (/showthread.php?tid=54776) |
How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-24-2012 [eluser]frankabel[/eluser] Hi all, I just want make something like: Code: $this->load->view($str_with_view_content, $data, TRUE); instead of: Code: $this->load->view('path_of_view_content', $data, TRUE); What options I have to archieve this? Thanks in advanced. Frank How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-25-2012 [eluser]TWP Marketing[/eluser] [quote author="frankabel" date="1348533897"]Hi all, I just want make something like: Code: $this->load->view($str_with_view_content, $data, TRUE); instead of: Code: $this->load->view('path_of_view_content', $data, TRUE); What options I have to archieve this? Thanks in advanced. Frank[/quote] Place the variable: $str_with_view_content, inside your data array: Code: ... How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-25-2012 [eluser]frankabel[/eluser] With "str_with_view_content" I mean a string that have the html with PHP tags inside. So, what I want is avoid load the content from a file, and load it from a string var. How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-25-2012 [eluser]CroNiX[/eluser] http://ellislab.com/codeigniter/user-guide/libraries/output.html How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-26-2012 [eluser]frankabel[/eluser] Thanks all for the replies, but seem to me that I don't explain myselft well and replies are not related to my questions. So, lets put this question in verbose mode ![]() view/viewfile.php: Code: <html> controller/controllerfile.php Code: class Controllerfile extends CI_Controller { That is the normal CI workflow but what I want is something like: controller/controllerfile.php Code: class Controllerfile extends CI_Controller { so, what I need is pass the view content to the "load->view" function as a var instead of a file name, my goal is kind of allow users define view content and store into the database, not in the file system. Thanks for your patience. Frank How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-26-2012 [eluser]CroNiX[/eluser] Read the link in my post. It tells how to do exactly what you are asking....set a string as the output. You don't use "load" for this... load loads files. How can I want pass a string with the view content instead of a file name when loading a view? - El Forum - 09-26-2012 [eluser]frankabel[/eluser] Thanks again. I read the link first time you sent it but I don't get it ![]() If you are refering to: Code: $this->output->set_output($data); well, I really don't know what Code: $data Code: $data Code: '<html><body><h1> My name is:<?php echo $name?></h1></body></html>' Code: echo $name |