无法在代码点火器 3 中加载视图错误


Unable to load view error in codeigniter 3

>Controller:

class Welcome extends CI_Controller {
    public function __construct() 
    {
        parent::__construct();
        if(!is_logged_in()){
            redirect('admin');
        }
    }
    public function index()
    {
        $this->load->view('templates'sub_header');      
        $this->load->view('welcome_message');
        $this->load->view('templates'footer');
    }
}

调用控制器时,应简单地按顺序加载三个视图。相反,我不断收到错误"无法加载请求的文件:模板''sub_header.php"。

需要注意的重要一点是,此代码在本地主机上运行良好,但在 godaddy 子域上存在问题。

我在配置文件中定义了一个基本网址,它似乎工作正常。

另一方面,另一个控制器在任何地方都工作正常:

public function index()
    {
        if( is_logged_in() )
        {
            redirect('welcome');
        }
        $this->form_validation->set_error_delimiters('<div class="text-danger">', '</div>');
        $this->form_validation->set_rules('username', 'UserName', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required|min_length[4]');
        $this->load->view('templates/header');
        if($this->form_validation->run() == FALSE)
        {
            $this->load->view('auth/login_view');
        }
        else
        {
            // Check the entered value against db
            $this->load->model('auth/admin_model');
            $result = $this
                    ->admin_model
                    ->verify_user($this->input->post('username'),$this->input->post('password'));
            if($result != false)
            {
                $username = $this->input->post('username');
                $status = $result->status;
                if($status == 1)
                {
                    $user_roles = $this->admin_model->get_user_access_roles($result->id);
                    $this->session->set_userdata('username', $username);
                    $this->session->set_userdata('user-management',$user_roles->user_management);
                    $this->session->set_userdata('client-information',$user_roles->client_information);
                    $this->session->set_userdata('master-metadata',$user_roles->master_metadata);
                    $this->session->set_userdata('reports',$user_roles->reports);
                    redirect('welcome');
                }
                else 
                {
                    $data['error_message'] = "Account is disabled. Get in touch with system administrator !";
                    $this->load->view('auth/login_view',$data);
                }
            }
            else
            {
                $data['error_message'] = "Invalid UserName or Password. Try Again !";
                $this->load->view('auth/login_view',$data);
            }
        }
        $this->load->view('templates/footer');
    }
视图在管理控制器

中完美加载,但在登录后,当管理控制器重定向到欢迎控制器时,视图停止加载。控制器之间的唯一区别是,在管理控制器中我调用标头,而在欢迎中我调用sub_header但两个文件都存在于视图文件夹中。

'更改为此/

public function index()
{
    $this->load->view('templates/sub_header');    # Changed   
    $this->load->view('welcome_message');
    $this->load->view('templates/footer'); # Changed 
}

并确保文件存在