Php hmvc编码点火器

Php hmvc编码点火器,php,model-view-controller,codeigniter,module,hmvc,Php,Model View Controller,Codeigniter,Module,Hmvc,我已经学习了codeigniter的基础知识,现在正在学习模块 我的问题:我在模块文件夹中创建了两个文件夹,第一个模块和第二个模块 在控制器内的第一个模块中,我的代码: <?php class First_module extends MX_Controller { public function index() { $this->load->view('first_module_view'); } } ?

我已经学习了codeigniter的基础知识,现在正在学习模块

我的问题:我在模块文件夹中创建了两个文件夹,
第一个模块
第二个模块

在控制器内的第一个模块中,我的代码:

<?php
    class First_module extends MX_Controller {
    public function index()
    {
        $this->load->view('first_module_view');            
    }
}
?>
second_模块
控制器页面:

<?php
class Second_module extends MX_Controller {
    public function index()
    {
        $this->load->view('second_module_view');
    }
}
?>
我试图使用第二个模块的控制器在
第一个模块
视图中部分查看第二个模块视图,但这不起作用。
单独而言,这两个代码都工作正常,但
Modules::run()
似乎不工作


我遗漏了什么吗?

我知道您已经找到了解决方案,但这并不能完全回答您提出的问题,但是,我通常会这样做:

       <?php
            class First_module extends MX_Controller {
            public function index()
            {
                 $content = array();

                //send content array to 2nd view and return everything as a string to be added as content to the first view

               $content["second_view"] = $this->load->view('second_module_view',$content,true);

               $this->load->view('first_module_view',$content);            
            }
        }
        ?>

然后,第一个模块视图变为:

<html>
<body>
    <h1> hey this is first module </h1>
    <?php 
        echo $second_view;
    ?>
</body>

嘿,这是第一个模块

我没有专门使用模块,但是这是我使用控制器和视图的方式。我会尽我所能限制从视图中调用模型和模块。只需传入从您的模型在控制器中生成的变量。

只需确认,您可以告诉is模块::$locations数组在config?um中设置。。我已经设置了
$config['modules\u locations']=array(APPPATH.modules/'=>'../modules/',)已解决…:)我没有在echo Modules::run('second_module/second_module')中包含索引它在代码中正确执行:-
echo Modules::run('second_module/second_module\index')哦,你真的不想从一个控制器调用另一个控制器。这就是为什么它被称为模块分离。您可以通过引用其他模块(first_module/first_module_view.php)来共享模型和视图。如果你开始从一个控制器调用另一个控制器,你会有各种各样的头痛。我倾向于同意Thom的观点,这就是为什么MVC首先被创建来分离东西。。。无论如何,如果您确实需要这样做,请不要将html、head和body标记放在第二个视图中,因为这样会生成语义不正确的websiteNice,这似乎是使用CodeIgniter实现HMVC(而不是简单的MVC)页面的正确方法。
       <?php
            class First_module extends MX_Controller {
            public function index()
            {
                 $content = array();

                //send content array to 2nd view and return everything as a string to be added as content to the first view

               $content["second_view"] = $this->load->view('second_module_view',$content,true);

               $this->load->view('first_module_view',$content);            
            }
        }
        ?>
<html>
<body>
    <h1> hey this is first module </h1>
    <?php 
        echo $second_view;
    ?>
</body>