[SOLVED] This MVC works without $this->uri->segment(n), But Why? |
[eluser]Juan Velandia[/eluser]
Hello Everyone I have this MVC Model: Code: function get_sections() // I have a table with sections Controller Code: function __construct() view_section: Code: <? view_article: Code: <?php foreach ($articles as $row): How does the $section variable is defined with the right idsection? usually one should use $this->uri->segment(n) to define it as seen on the videos (http://codeigniter.com/tutorials/), but as you can see it is not necesary in this case. Someone knows why? thanks!
[eluser]solid9[/eluser]
Are you trying to dig a CMS? If the codes is not originally written by you. Then somewhere in the codes it is defined. Have you checked the SESSION? Have you checked the config? Have you checked the library? How about the MY_Model? Or the model? etc... You should check everything...
[eluser]Juan Velandia[/eluser]
Hello, all the code has been written by me from scratch, from a fresh CI download. It really works and it doesnt use anything fancy. I just set the DB settings and place the files, and it worked.
[eluser]solid9[/eluser]
you wrote it? then you don't know it? lol that's funny.
[eluser]CroNiX[/eluser]
Its because extra segments (beyond controller/method) get passed to the method automatically, and you are capturing it and using it in your method. Code: function article($section) Code: www.yoursite.com/controller/article/section-name If you just used Code: function article()
[eluser]CroNiX[/eluser]
The more parameters you automatically pass, they are taken in order. Code: public function some_function($uri_segment_3, $uri_segment_4, $uri_segment_5, etc) does the same as Code: public function some_function()
[eluser]Juan Velandia[/eluser]
Please hold your horses! I will have to read it carefully and english is not my best language... thanks a lot!
[eluser]solid9[/eluser]
That is a nice trick. Thanks a lot again CroNix. Cool!
[eluser]Juan Velandia[/eluser]
Cronix you are very kind, one more thing: And I have to understand that this Code: function article($section, $param1, $param2) is the same as this: Code: function article() thanks a lot, I owe you a beer! |
Welcome Guest, Not a member yet? Register Sign In |