CodeIgniter Forums
Small controller question - 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: Small controller question (/showthread.php?tid=13942)



Small controller question - El Forum - 12-12-2008

[eluser]copernicus[/eluser]
I have a site where there are some static pages and some dynamic pages, would it be better to have two separate controllers (static, dynamic) that just have the correct type of routing to them or to have one "pages" controller and have it load the appropriate model/view based on what the path in the URL is?


Small controller question - El Forum - 12-12-2008

[eluser]sophistry[/eluser]
hi copernicus,

welcome to CI! sounds like you might benefit from this auto-loading views technique i came up with.

it lets you put static pages in the views directory and your controller can load them inside a CI context without re-writing them or specifically coding a controller for each page (for example).

http://codeigniter.com/wiki/site_migrate/

if you are completely new to CI it will help to get familiar with CI itself first in order to understand how this code benefits your development process.

basically, it lets you "drop in" a fully functional static (or dynamic) existing website into the views directory of a new CI install and have it work inside a CI context (controllers, models, and views, etc...). then, when you are ready to start adding dynamic stuff/overriding the static pages, you just add a child controller and methods in that controller. the methods take precedence over the auto-loading of static view files.

cheers.