I have a problem. I have overriden CI’s default call to method by using a ‘_remap’ function. It all works as I should when I pass one parameter, which is of course the overriden method, (the second segment of the uri). However, following the user guide’s instructions, when I try to retrieve additional segments of the url via the method below, the $params array is empty? I’ve used a var dump on the $a variable on my main_view, and it always shows the array is empty, even when the 3rd segment of the uri is present.
The CI user guide states ‘Any extra segments afte开发者_运维技巧r the method name are passed into _remap() as an optional second parameter.’ (http://codeigniter.com/user_guide/general/controllers.html) But this doesn’t appear to be so. Does anyone know what I might be doing wrong?
class Services extends Controller {
var $group = 'services';
function Services()
{
parent::Controller();
$this->load->helper('url');
}
public function _remap($subPage, $params = array()){
$pageData = $this->page_builder->buildPage($this->group,$subPage);
if($subPage != 'index'){ $pageData['thisPage'] = $this->group .'/' . $subPage; }
else{ $pageData['thisPage'] = $this->group; }
$pageData['a'] = $params;
$this->load->view('main_view', $pageData);
}
}
Thanks.
I too had a similar problem, so I made little a tweak that worked for me:
$segs = $this->uri->segment_array();
$params=array_slice($segs, array_search($method, $segs));
精彩评论