![]() |
Why we just load views from files? - 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: Why we just load views from files? (/showthread.php?tid=25332) |
Why we just load views from files? - El Forum - 12-08-2009 [eluser]Unknown[/eluser] Hello, there. I'm new to CI and I have a good (in my view) question. Why we just load views from files? I mean, if you take a look at some template systems, like Smarty, you can see that they let you load (or include) templates from a variety of sources (for example, from a database). In CodeIgniter we don't have it. Views (that can be considered as some kind of templates) are just stored and loaded from files. I'm working on a small CMS that is inspired by Ruby's Radiant CMS. And it let the user create and edit layouts and snippets. Layouts are a little like views, but they're stored on the database. So, I've done the following adaptation, just cutting some parts from original CI_Loader class. Code: class MY_Loader extends CI_Loader That function works like _ci_load one, but instead of loading from a file, loads from a string buffer. Now I can retrieve a layout from a database and treat and load that as a normal view. As I'm new to CI, I wonder if that was a good solution and I ask you guys, that are more experienced. Thank you, Dirley Rodrigues Why we just load views from files? - El Forum - 12-08-2009 [eluser]Colin Williams[/eluser] If it works and it's not buggy, it's a good solution! EE 2.0 has functionality similar to this, so that functionality could be moved into CodeIgniter at some point. We'll have to wait and see. |