在CodeIgniter中的模块内创建模块 [英] Create modules inside a module in CodeIgniter
问题描述
我正在尝试使用CodeIgniter实现HMVC。我从bigbucket使用此库
I am trying to implement HMVC with CodeIgniter. I used this library from bigbucket
当我创建管理模块时,它对我来说很好用。但是现在我正在尝试在模块内部定义模块。因此,我的结构将如下所示:-
It works fine for me when i created admin module. But now i am trying to define module inside a modules. So, my structure will be like this :-
admmin是我的主要模块。页面是admin的子模块。我再次定义页面模块1)静态和2)动态的两个子模块。
Here "admmin" is my main module. And page is a sub module of admin. I again define two sub modules of page module 1) Static and 2) Dynamic.
当我使用url访问管理模块时:-
When i access the admin module using the url :-
http://localhost/ci_hmvc/index.php/admin
它起作用。但是当我尝试使用此URL访问子模块时:-
it works. But when i try to access the sub module using this url:-
http://localhost/ci_hmvc/index.php/admin/page
这给我404错误。
任何提示都会有所帮助。
Any hint will be helpful.
谢谢
推荐答案
那不是应该如何工作的。模块应该在模块中拥有自己的文件夹(即使您不想将模块分离,即使您仍然可以将它们放置在本地控制器,模型,视图文件夹中)。
That is not how it's supposed to work. A module should have it's own folder in modules (even though you can still place them in your native controller, model, view folders, if you don't want modular seperation).
您应该为每个模块的功能创建一个新方法。这样,它们仍将具有相同的属性和方法,并且毫无意义地拥有一个新文件夹。
You should just make a new method for each of the modules "functions". In that way they will still have the same properties and methods availaible, and there would not be a point, in having a new folder.
class Page extends MX_Controller {
public function __construct()
{
parent::__construct();
// Your constructor code
}
public function static()
{
// Your static page code
}
public function dynamic()
{
// Your dynamic page code
}
}
路由和调用模块,您可以在bitbucket页面上阅读全部内容。
Routing and calling the modules, you can read all about on the bitbucket page.
这篇关于在CodeIgniter中的模块内创建模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!