简体   繁体   English

根中的Codeigniter HMVC模块

[英]Codeigniter HMVC modules in a root

I'm new on Codeigniter HMVC. 我是Codeigniter HMVC的新手。 I read tut how to install and work with modules and it seems everything fine. 我读了tut如何安装和使用模块,似乎一切正常。

What I'm trying is to work with modules outside application folder, but no luck. 我正在尝试的是与应用程序文件夹外部的模块一起使用,但是没有运气。

I'm trying to browse to my url: localhost/contacts/admin 我正在尝试浏览到我的网址: localhost / contacts / admin

applications/config/config.php Applications / config / config.php

// Modular 
$config['modules_locations'] = array(
    APPPATH.'modules/' => '../../modules/',
);

ROOT/modules/contacts/controller/contacts.php ROOT /模块/联系人/控制器/contacts.php

class Contacts extends MX_Controller  {
    var $ci;
    public function __construct() {
        parent::__construct(); 
        $this->ci =& get_instance();
        $this->load->helper('url');
    }
    function admin() {
        echo 'Controller: ROOT/Modules/Contacts<br />';
        $this->load->view('admin');
    }
}

Here it seems everything OK - Controller loaded, but then I start with view, something going crazy: 在这里看来一切正常-控制器已加载,但随后我从视图开始,有些事情变得疯狂了:

I have 2 same modules. 我有2个相同的模块。 1 in a ROOT catalog, another in application catalog. 1在ROOT目录中,另一个在应用程序目录中。 Controller is loaded from ROOT module, but view is from application catalog (application/modules/contacts/views/admin.php). 控制器是从ROOT模块加载的,但是视图是从应用程序目录(application / modules / contacts / views / admin.php)加载的。

Then I delete view catalog in application/modules/contacts/view , get error: 然后我删除application / modules / contacts / view中的视图目录,得到错误:

Unable to load the requested file: admin.php 无法加载请求的文件:admin.php

If I delete modules catalog from application folder, it load default view. 如果我从应用程序文件夹中删除模块目录,它将加载默认视图。

So can anyone help figure out how to work with HMVC, because until now I can't get it how it works. 因此,任何人都可以帮助弄清楚如何使用HMVC,因为直到现在我还无法了解它是如何工作的。

what about !? 关于什么 !? :

$config['modules_locations'] = array(
   APPPATH.'modules/' =>  $['HTTP_HOST'].'/ROOT/modules',
);

by default your view need to in the, 默认情况下,您的视图需要位于

ROOT/modules/contacts/views/

But if you want you custom Views folder, its been answered before. 但是,如果您要自定义Views文件夹,则之前已经对其进行了回答。 Please Refer this below link. 请参考以下链接。

Loading view outside view folder with CodeIgniter 使用CodeIgniter将视图外部加载到视图文件夹中

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

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