问题
I am trying to implement HMVC with CodeIgniter. I used this library from bigbucket
CI HMVC Library
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 :-
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.
When i access the admin module using the url :-
http://localhost/ci_hmvc/index.php/admin
it works. But when i try to access the sub module using this url:-
http://localhost/ci_hmvc/index.php/admin/page
It gives me 404 error.
Any hint will be helpful.
thanks
回答1:
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
}
}
Routing and calling the modules, you can read all about on the bitbucket page.
回答2:
I Discussed this with my colleagues and senior developers. And after a long discussion we are agree on a point that "We can implement this structure but this is not a good practice and will raise problems and complexity in the maintenance."
来源:https://stackoverflow.com/questions/16835155/create-modules-inside-a-module-in-codeigniter