Codeigniter:“_remap”第二个参数(应该是 url 段)返回空?
我有一个问题。我已经使用“_remap”函数覆盖了 CI 对方法的默认调用。当我传递一个参数时,这一切都按我应该的方式工作,这当然是重写方法(uri 的第二段)。但是,按照用户指南的说明,当我尝试通过下面的方法检索 url 的其他部分时,$params 数组为空?我在 main_view 上的 $a 变量上使用了 var 转储,并且它始终显示数组为空,即使存在 uri 的第三段也是如此。
CI 用户指南指出“方法名称后面的任何额外段都会作为可选的第二个参数传递到 _remap() 中。” (http://codeigniter.com/user_guide/general/controllers.html)但事实似乎并非如此。有谁知道我可能做错了什么?
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);
}
}
谢谢。
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 after 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了类似的问题,所以我做了一些对我有用的调整:
I too had a similar problem, so I made little a tweak that worked for me: