michaelfox + remap 2
Wiki | CodeIgniter
october 2009 by michaelfox
Would you like to serve up already-existing HTML and PHP pages inside a CI context?
Migrate a site to CI perhaps? This is how I did it with a minimum of fuss.
One brute force way to migrate a site to CI is to write a controller method for every static page. But, if you are using CI already, then you probably like to find efficient ways rather than brute force ways.
Instead of mapping pages to controllers by hand, this code uses _remap() to handle incoming URIs. It uses a base controller that you extend. The base controller first checks if there is a controller method anywhere in the child or parent class. If there is not a controller method, it checks the filesystem for a matching view file. If there is a matching view file, then it loads it through the normal CI load->view() method. If there is no view file, you get the normal CI 404 error.
Drop this base controller in place with a “skeleton” child class (optional but recommended) and you can put static pages in the views directory. Your controller will load them as if they were view files - inside a CI context - without re-writing them or specifically coding a controller for each page. Migrate your existing site in one fell swoop. Then you can piece out the functionality by adding controller methods so that it progressively gets more CI-like.
codeigniter
migrate
library
php
remap
Migrate a site to CI perhaps? This is how I did it with a minimum of fuss.
One brute force way to migrate a site to CI is to write a controller method for every static page. But, if you are using CI already, then you probably like to find efficient ways rather than brute force ways.
Instead of mapping pages to controllers by hand, this code uses _remap() to handle incoming URIs. It uses a base controller that you extend. The base controller first checks if there is a controller method anywhere in the child or parent class. If there is not a controller method, it checks the filesystem for a matching view file. If there is a matching view file, then it loads it through the normal CI load->view() method. If there is no view file, you get the normal CI 404 error.
Drop this base controller in place with a “skeleton” child class (optional but recommended) and you can put static pages in the views directory. Your controller will load them as if they were view files - inside a CI context - without re-writing them or specifically coding a controller for each page. Migrate your existing site in one fell swoop. Then you can piece out the functionality by adding controller methods so that it progressively gets more CI-like.
october 2009 by michaelfox
Copy this bookmark: