CodeIgniter Forums
Controllers in sub-folders - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Controllers in sub-folders (/showthread.php?tid=15268)



Controllers in sub-folders - El Forum - 01-30-2009

[eluser]GSV Sleeper Service[/eluser]
this is puzzling me, I've put a controller in a sub-folder called 'maintain'
the controller is called 'Jobs', in this controller I have a method called 'detail' which takes one parameter ($job_id)

the detail method looks like this
Code:
function detail($job_id)
{
    echo "job_id = $job_id";
}

when I test this in my browser using http://domain.com/maintain/jobs/detail/123 I see on the screen

job_id = detail

WTF?! if it thinks detail is the parameter then how does CI know to use the detail method?


Controllers in sub-folders - El Forum - 01-30-2009

[eluser]kevinprince[/eluser]
Thats is odd but try this.

Code:
function detail ($job_id = '')
{
    echo "job_id = $job_id";
}



Controllers in sub-folders - El Forum - 02-02-2009

[eluser]GSV Sleeper Service[/eluser]
[update]

found the problem, a colleague had made a MY_Controller.php, which included a _remap() function. had to change the following in the _remap() method
Code:
//next line does not work for controllers in sub-folders
//call_user_func_array(array($this, $method), array_slice($this->uri->segment_array(),2));
call_user_func_array(array($this, $method), array_slice($this->uri->rsegments,2));