• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Am I understanding HMVC correctly?

I'm working toward a complex application and I think that eventually I'll need HMVC, but not sure.

In essence, I have many views where there will be several sub-views, each with their own logic and functionality. In fact, each of the sub-views is equivalent to a separate controller function.

The best example is where an Admin selects a user from a list, and goes on to edit that user. I currently have two controller functions: one for listing users, one for editing the chosen user. If I want to put these on the same page, however, I think I need to use HMVC. Is that right?

At first I thought it was simply a matter of one sub-view using ajax to requery the second sub-view, but now I realise that the sub-views are more than just 'views', they are actually controller functions.

Not sure if this makes sense, but any clarification would be appreciated!

HMVC basically allows you to chunk up your application into smaller sections. So you can have one module named "admin" for all admin related stuff, another the users control panel. For each module you make a controller, and for each page in that module you add a method to handle that page.

From what your saying, your trying to chunk it up a little far in my opinion. How you could set it:

class Admin extends Controller {
   function index() {
      // Load the page here
   function viewusers() {
      // Use this to get the HTML to load into the page

   function edituser($id) {
      // User this to edit the user


With index being a shell, and viewusers and edituser loading into the index with ajax or just use then as pages. You might want to look around the web and read up a little more on HMVC and MVC to get a better idea on how to chunk up your modules and such.

Edit: This article might be of some help.

Thanks dudeami0. Good explanation. Good article too.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.