Modular HMVC - Libraries on Steroids [Updated x3] |
[eluser]wiredesignz[/eluser]
This is an example of a base controller using the _remap() method to load modules HMVC style. Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Code: http://127.0.0.1/base/admin/products/edit The admin/products module: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
[eluser]Edemilson Lima[/eluser]
I find your implementation to modules very elegant and follow the CI standard better than any other I have found. But I would like to know what do you have against extending the core. Using $this->modules->load() is in some way better than $this->load->module()? Personally I don't like changes to the core, but I don't see anything bad with extending it. How do you call the functions setup(), add() and edit() in your examples above? Also, there is always necessary to have a contructor or the index() function could be called by default? Code: class Modules Code: class Product extends Controller { ![]() Code: class _login extends Modules //as a psuedo-controller
[eluser]Edemilson Lima[/eluser]
Pseudo means false. But psuedo have another meaning, I think.
[eluser]zdknudsen[/eluser]
A little competition, eh? Great! If I understand your library right, I will try to explain how I believe our solutions differ. The philosophy behind Matchbox, was to give developers additonal possibilities in means of organization, whithout having to change which methods to call in order to load resources, etc. Effectively, what this means is that developers are able to take any standard CI application they've made, split it into smaller components and place said components in module folders and still have them work (e.g. no need to go back into the files and change the resource-loading methods). The main thoughts behind "Modular Separation - Nested MVC" are to first of all not alter the core (which Matchbox does in a high degree) and enable one to use HMVC. Both of which probably wont ever make it into Matchbox, which is why this is great for the end-user who can choose whatever they see fit ![]() (By the way, would you consider renaming your library to something else than Modular Separation? That is what my previous version of Matchbox was called, just to avoid any confusion. Or perhaps it doesn't matter. Just think about it ![]()
[eluser]Edemilson Lima[/eluser]
It could be called "Pseudo-HMVC". :-) I don't care about the library name, but I do prefer to use: Code: class Products extends Module { Code: class Products extends SomeFussName {
[eluser]wiredesignz[/eluser]
Quote: But I would like to know what do you have against extending the core. @Edemilison: If I want to use Matchbox also, then other core extensions would cause lots of trouble to make things work together. I prefer my Modules Library, it is very versatile, and I can use Matchbox also. You can rename the Modules library to anything you like, I like Modules because I load many modules at once, and a Module is the loaded object, not the library itself. Yes you must always have a constructor, so your Module gets extended properly, you do not need an index() method, if you want a default function to run after loading then call it from your constructor. Calling functions is the same format as you would call a Model or Library, I prefer to use render() when I want the Module to output its view, like so: Code: <?php echo $this->search->render(); ?> @Zach: I was being cheeky with that name ![]() I hope you all try it out, I have been experimenting with it all day and have found many uses. It's just up to your imagination. Maybe it should be called Libraries on Steroids ![]()
[eluser]zdknudsen[/eluser]
Ooh, I didn't realize our libraries could work together ![]() Namewise you could also go with "Modular and Nested HMVC".
[eluser]wiredesignz[/eluser]
Yes Zach, your Modular MVC apps can then contain my Modules also. ![]()
[eluser]wiredesignz[/eluser]
Quote:How do you call the functions setup(), add() and edit() in your examples above? @Edmilison: The controller uses the _remap() method as detailed in the CI user guide. It grabs the first two URI segments to determine what module to load and what function to call. The module then grabs any data from the remaining URI segemnts and does its thing. thats HMVC ![]() |
Welcome Guest, Not a member yet? Register Sign In |