Jump to content

MVC


armsteadj1

Recommended Posts

I am building my own MVC to fit the specs of one of my projects but I am not sure how to make the page more dynamic. All of the MVC examples that I have seen have built a single page basically. What if I need to build a menu to put on the page and also build whatever page they are at and then display them together? What if the menu needs to depend on the Module?

 

My first thought is this:

 

    Have the Controller have an array to hold the build modules. So you can have it build the module that needs to be displayed and store it in an array, then build the menu and store it in the array. Then after it is done building all of the needed modules it will call the default template(basically another View) which will just output the menu and module wherever they should be placed. I am not sure if this breaks the point of MVC or not. I want to hold true to MVC thats why i figured using its own mechanics to build anything else needed would work best. Any more ideas or thoughts?

 

 

class ActionController {

/*Verifies and calls Module Function of Action class

/*Calls and outputs View

 

/*ADD Loop through array and build View for each and then call default View to display the Menu and Module

}

 

class FrontController extends ActionController {

/*Grabs params builds array with them, verifies/includes/creates Action class

 

/*ADD: verify/include/create Menu class and put both(above) in an array

}

 

class View extends ActionController {

/*Verifies template and includes it

}

 

 

Thanks! Hopefully this isnt to confusing and i explained it well enough for someone to help!

 

James

Link to comment
Share on other sites

  • 4 weeks later...

Thoughts:

* Open cakephp and dig through there code.

* Open Codeigniter and dig through there code.

* Google up and split open/look through 2-3 random frameworks online

 

After that you'll know exactly what your wanting to do.  If you have never done MVC before then it might be better to get familiar with something already out there.

It's not required but you'll have a better idea on something that is tried/true before you forge off and make another MVC pattern with no framework attached to it.

 

Overall MVC isn't hard to keep even without a framework.  Just seperate your content from your programming.  Work on logical class structures and model structures.  Work on logical view setup.  The hard part is making them work together (generally that's what a framework does).  It connects the 3 types (models, views, and controllers) and mixes them together in a coherent fashion so they are "Aware" of one anothers presense and but used together without a lot of working making them aware of each other.  IF you create a class...a model...and a view.  And that's it they have NO way of knowing between themselves that the others exist.  Meaning you have to go out of your way to make the model realize what class it's meant to be used with, and telling the controller what view is suppose to be showing it's content.  Then when you have to add in your JS and CSS it adds another layer to the problem.  I recommending contructing a "Basic" framework around whatever your doing so the models know what controllers they go with and the controllers can easily access the models they need.  You also want an easy way to tell a given controller what view it's suppose to open..

 

Folder structure is also very important and can go a long ways toward guaranteeing you have a decent development experience with the minimal of hassle.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.