converting from php $_GET variables to code igniter
-
29-09-2019 - |
Question
I am learning to use the CodeIgniter framework. I am coming form a world where get variables determined which body file to include in the index.php.
So with the MVC style coding I am unsure how to have a skeleton view which subsequent views are just the body of the page.
any Ideas?
Solution
My suggestion is to try and load multiple views based on the data being sent through the $_GET variable. The documentation for CodeIgniter explains how to do this:
http://codeigniter.com/user_guide/general/views.html
The skeleton parts of your site would always be loaded by the controller with the part that changes dependent on the $_GET data.
OTHER TIPS
In CodeIgniter, GET variables(as in querystrings, eg. ?var1=alice&var2=bob) are not normally used for passing data, because they are disabled by default. Instead, URL segments (see http://codeigniter.com/user_guide/general/controllers.html#passinguri) or POST variables are used.
If it is necessary to use GET variables, thus enabling use of $_GET and/or $this->input->get(...), see this:
How can I use GET forms with CodeIgniter?
Edit: This may be useful in regards to loading a subv-iew within a main view:
http://codeigniter.com/wiki/Header_and_footer_and_menu_on_every_page/