Welcome Guest, Not a member yet? Register   Sign In
Controllers in sub-folders
#1

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

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

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

[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));




Theme © iAndrew 2016 - Forum software by © MyBB