我是新來的代碼點火器框架。我有問題從控制器調用視圖。無法從phph中的控制器加載視圖 - codeigniter
我在我的應用程序/控制器/文件夾3個三個控制器中我的意見/模板/文件夾 employee.php
,home.php
和dashboard.php
和5次 header.php
,footer.php
,sidebar.php
,template.php
和topmenu.php
並在我的主要意見文件夾3意見 addEmployee.php
,home.php
和dashboard.php
我能夠擊中家庭和儀表板控制器,但無法命中員工控制器加載addEmployee視圖。
這是我的看法addEmployee.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<title>Add Employee</title>
<div class="main-content">
<?php include 'template/topmenu.php' ?>
<!-- PAGE CODE STARTS BELOW FROM HERE -->
</div>
employee.php控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Employee extends CI_Controller {
public function __construct() {
parent::__construct();
$this -> load -> model('employee_model');
}
public function index() {
$data['header'] = 'template/header';
$data['sidebar'] = 'template/sidebar';
$data['main_content'] = 'addEmployee';
$data['footer'] = 'template/footer';
$this->load->view('template/template',$data);
}
function functionToTestgetAndSaveEmployeeDetailsResult() {
$result = $this -> getAndSaveEmployeeDetails();
print_r($result);
}
}
?>
模板/視圖的template.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<?php
$this->load->view($header);
$this->load->view($sidebar);
$this->load->view($main_content);
$this->load->view($footer);
?>
的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
的config/config.php文件
$config['base_url'] = 'http://localhost:8050/test/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
我使用這個網址訪問該意見
http://localhost:8050/test/ for home
http://localhost:8050/test/dashbaord for dashbaord
http://localhost:8050/test/addEmployee for addEmployee
家和儀表板意見由此工作,但addEmployee沒有。
我也曾嘗試這些URL,但沒有運氣
http://localhost:8050/test/employee/addEmployee
http://localhost:8050/test/index.php/addEmployee
http://localhost:8050/test/index.php/employee/addEmployee
任何想法,什麼是錯的這個addEmployee看法?或任何鏈接?
https://www.codeigniter.com/user_guide/general/views.html#loading-multiple -views – user4419336