模块加载破坏了视图加载(旧代码) [英] Module load breaks view load (old code)

查看:84
本文介绍了模块加载破坏了视图加载(旧代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试用codeIgniter和Modular Extension。到目前为止,我已经按照 wirebuck上的安装说明进行了安装。现在,我正在尝试教程 HMVC:简介和应用来自NetTuts。

I'm trying out codeIgniter and the Modular Extension. So far I followed the installation instructions from wiredesignz on bitbucket. Now I'm trying the tutorial HMVC: an Introduction and Application from NetTuts.

我正在使用CodeIgniter 2.1的实际版本和Modular Extension的实际版本(从bitbucket下载.zip版本)进行此操作

I'm doing this with the actual version of CodeIgniter 2.1 and the actual version of the Modular Extension (downloaded the .zip version from bitbucket).

在我尝试从另一个模块的控制器运行方法之前,所有方法都可以正常工作。

All works fine until I'm trying to run a method from a controller of another module.

简而言之,设置是有两个模块(站点和登录)。在网站的控制器中,有site.php( /modules/site/controllers/site.php ),其中包含一种检查用户是否登录的方法。该方法将退出如果在未登录的情况下访问站点,则执行脚本。由于此方法在逻辑上属于登录模块,因此作者建议将其移至该位置。因此将其移至 /modules/login/controllers/login.php

The setup in short is, that there's two modules (site & login). Within the site's controllers there's site.php (/modules/site/controllers/site.php) with a method that checks if a user is logged in. This method would exit the script execution if accessing the site without being logged in. As this method logically belongs to the login module, the author suggests moving it there. So it then is moved to /modules/login/controllers/login.php.

现在的问题是,如何从站点模块内部访问登录模块的方法。在本教程中经过稍微调整的代码:

The problem now is, how to access the method of the login module from within the site module. The slightly adjusted code from the tutorial:

// modules/site/controllers/site.php

function __construct()  
{  
    // parent::Controller();
    // replaced with:
    parent::__construct();

    // modules::run('login/is_logged_in');
    // replaces with:
    $this->load->module('login')->is_logged_in();
}  

就像这样,我遇到了错误:

Like this I'm getting an error:


无法加载请求的文件:logging_in_area.php

Unable to load the requested file: logged_in_area.php

该方法问题所在的站点模块也是如此:

The method in question is inside the site module as well:

// modules/site/controllers/site.php

function members_area()
{
$this->load->view('logged_in_area');
}

脚本将一直执行直到 load->。查看行并产生错误。通过以下行从站点控制器中运行 is_logged_in 方法,访问 logged_in_area.php 没问题:

The Script executes right until the load->view line and produces the error. There's no problem accessing the logged_in_area.php with running the is_logged_in method from within the site controller with the line:

$this->is_logged_in();

有什么想法吗?

编辑:

应用程序树:

/application
  /...
  /modules
    /login
      /controllers
        login.php
      /models
      /views
        login_form.php
        signup_form.php
        signup_successful.php
    /site
      /controllers
        site.php
      /models
        membership_model.php
      /views
        logged_in_area.php

PS:如何获取更多信息错误? CodeIgniter似乎对错误输出非常保留...

PS: How can I get more INformation about the error? CodeIgniter seems to be very reserved about error output ...

推荐答案

如文档此处要从另一个模块中加载视图,您需要使用扩展的MX控制器和方法:

As stated in the documentation here to load a view from within another module, you need to use an extended MX controller and a method:

<?php echo Modules :: run('module / controller / method',$ param,$ ...); ?>

这篇关于模块加载破坏了视图加载(旧代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆