1
我發現我的路由根本不起作用,當我輸入它表示'找不到對象'的路由時。它默認加載索引函數,並且工作,但路由不會。CodeIgniter路由不起作用
路線:
$route['default_controller'] = 'personeelcontroller';
$route['personeelcontroller/editPersoon'] = 'maincontroller/editPersoon';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['personeelcontroller/onInit'] = 'personeelcontroller/onInit';
$route['personeelcontroller/index'] = 'personeelcontroller/index';
控制器:
class PersoneelController extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('PersoneelModel');
$this->load->model('ProjectModel');
$this->load->helper('url_helper');
}
public function index(){
$data['personeel'] = $this->PersoneelModel->getPersonen();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->view('urls/home' , $data);
}
public function onInit()
{
$data['projecten'] = $this->ProjectModel->GetProjecten();
$this->load->view('urls/projects' , $data);// laad deze view wanneer methode wordt opgeroepen
}
public function editPersoon(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('id', 'Id', 'required');
$this->form_validation->set_rules('name', 'Name', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('urls/failed');
}
else
{
$this->PersoneelModel->editPersoon();
$this::index();
}
}
}
*注意:您的命名你的類錯在這裏閱讀* http://www.codeigniter.com/user_guide/general/styleguide。 html#文件命名 – user4419336
像'$ route ['default_controller'] ='personeelcontroller'的路由;' – user4419336
對不起,這是一個錯字。如果這是錯誤的,它不會執行返回視圖的索引方法。 @ wolfgang1983 – BrianM