![]() |
ME HMVC using base modules and child modules - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: ME HMVC using base modules and child modules (/showthread.php?tid=26959) |
ME HMVC using base modules and child modules - El Forum - 01-27-2010 [eluser]wilso417[/eluser] Hey guys, new to the boards. Long time developer, new to CI + ME HMVC user. Looked on these boards and google for hours and could not find a solution to my problem. I am going to be creating a new CMS. I noticed in my previous CMS I was copying a lot of the same functionality in each module, so i thought using the HMVC would be best for me. I really like it so far but am having some trouble setting up a base module and having child modules inherit from it. Here is an example of what I want to do. I want a base module called Content which will contain my common code. I then want a module called News whose controller would inherit from the Content controller. class Content extends Controller { function __construct() { parent::Controller(); } function content_not_found() { $this->load->view('notfound'); } } class News extends Content { function __construct() { parent::__construct(); } function display_news() { // pseudocode to find news items in db if (!$found) { $this->content_not_found(); } } } The problem is of course, CI returns 'Unable to locate the file: notfound.php'. I know this is probably because CI is looking for that view file in my News module folder, not the Content module folder. I know not having News inherit from Content and then having News just 'use' that module: $this->content->content_not_found() would work, but this would create more redundant code. Anyone try to use a similar approach? ME HMVC using base modules and child modules - El Forum - 01-28-2010 [eluser]flaky[/eluser] include the file at the beginning, then you can extend it at the news.php ( I had the same problem ) Code: //I'm just guessing the path ME HMVC using base modules and child modules - El Forum - 01-28-2010 [eluser]wilso417[/eluser] Yeah, I have that in: require_once(APPPATH.'modules/content/controllers/content'.EXT); If I didn't get that in I would be getting a class 'Content' not found error, not a template error. I think the issue is that $this->load->view() is looking in modules/news/views when it should look in modules/content/views. ME HMVC using base modules and child modules - El Forum - 01-28-2010 [eluser]wilso417[/eluser] The only way i've gotten my parent module to see it's template is by putting the template in application/views/. However, this kind of defeats the purpose of the nice organization of modules. Anyone know of a better solution? |