Automatic views - 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: Automatic views (/showthread.php?tid=36428) |
Automatic views - El Forum - 12-01-2010 [eluser]dailygrind[/eluser] I'd like to share my code for automatic views (it's a bit rails-like) and get suggestions. I have an application view: "./views/layout/application.php" just like the one below Code: <!DOCTYPE html> and a main controller: Code: <? This way you can have a default application view with automatic views: en/home/method => will load ./views/home/method.php en/home/method => will load ./views/home/method_en.php (if exists) If you want to use other layouts other than defaults you can just set Code: $this->has_layout = false; in your method/constructor and use whatever you like. It will also load into "head_code" any view called with the "_init.php" extension if they exist. I don't know if this is a good idea, but I was just looking for a way to emulate Rails "content_for" in views. Does this make sense to you? How do you structure your application views? Ciao! |