简体   繁体   English

代码点火器hmvc模板不起作用

[英]code igniter hmvc templates not working

I have this templates folder in my new hmvc project that I am setting up. 我要设置的新hmvc项目中有此模板文件夹。

For my controllers 对于我的控制器

Template.php codes Template.php代码

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Template extends MX_Controller{

    function view(){

        $this->load->view('one_view');
    }
}

?>

one_view.php one_view.php

<h1>Hello</h1>

When I go to my browser and type: 当我进入浏览器并输入:

localhost/ci_hmvc/templates/view

it always says that 404 Page Not Found. 它总是说404页面未找到。 No matter what tutorial I watch its almost the same code and I copied every code they use but it doesnt work. 无论使用什么教程,我都看它几乎相同的代码,并且复制了他们使用的每个代码,但是它不起作用。

PS: I am using htaccess so theres no index.php in my url. PS:我正在使用htaccess,所以我的URL中没有index.php。

It should be: 它应该是:

localhost/ci_hmvc/template/view

Your controller and file name is Template and Template.php not Templates 您的控制器和文件名是TemplateTemplate.php而不是Templates

Side Note: 边注:

Or if you still want to use as templates than add route for this controller as: 或者,如果您仍想用作模板,而不是为此控制器添加路由,则为:

$route['templates'] = "template";

Second solution is that, change your file and controller name as templates . 第二种解决方案是,将文件和控制器名称更改为templates

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM