• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Small controller question

#1
[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?

#2
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.