我是CI的新手,我通过视图文件传递参数,例如
<a href="<?php echo base_url('projects/project_detail/'.$project_info['project_id']);?>" class="button small">More Details</a>
我试图通过控制器查看特定id的内容。
public function project_detail($id){
$this->load->helper('url');
$data['content_for_layout'] = 'projects/project_detail/'.$this->id;
$data['project'] = $this->project_model->get_project_detail($this->id); //folder/filename in which data is present.
$this->load->view('layouts/default', $data);
}
projects/project_detail/1
=内容存在的地方
layouts / default想要在此文件中显示内容。
我收到错误 -
Unable to load the requested file: projects/project_detail/.php
在路线档案中,我已经进行了类似的更改
$route['projects/project_detail/(:num)'] = "projects/project_detail/$1";
帮我打开projects / project_detail
中id = 1的内容答案 0 :(得分:0)
改变这一点;
$data['content_for_layout'] = 'projects/project_detail/'.$this->id;
$data['project'] = $this->project_model->get_project_detail($this->id);
对此;
$data['content_for_layout'] = 'projects/project_detail/'.$id;
$data['project'] = $this->project_model->get_project_detail($id);
删除&#34; $ this&#34;来自身份证。您正在使用您传递给该函数的ID,而不是该对象的ID。
另外,我不认为您需要使用的路线。