Background:
I'm having some trouble understanding exactly how to best use controllers in an MVC architecture.
I have a webapp that follows this URL scheme:
/
- main index/static-page
- static pages/categories
- index for specific categories/categories/users
- index for users of specific categories/categories/users/id#/user-name
- specific user for specific categories/categories/event-type-A
index for events related to specific categories/categories/event-type-A/id#/event-name
- specific event for specific categories/categories/event-type-B
index for events related to specific categories/categories/event-type-B/id#/event-name
- specific event for specific categories
*Note: This URL structure is similar to StackOverflow's in that malformed URL's (wrong event-name
s) are automatically corrected if the id#
exists.
Question:
Since categories
, users
, and event-type
s each have unique functionality associated with them (i.e. editing users, manipulating events, etc.), they are all contollers of their own (right?). And since event-type-A
and event-type-B
are very similar, they share common functionality extended from an events
class.
How do you suggest that I organize my controllers such that they follow "standard practice" in OOP and MVC design?
I currently have a Pages
class for my static pages, and I was expecting to have a categories
class that calls a users
class, event-type-A
and event-type-B
classes that (as described above) are extensions of an events
class... but from here I'm unsure of how best to proceed.
Any simple/pseudo code examples would be greatly appreciated.
Additional Information:
FYI: I am using PHP/MySQL. I have been trying to learn MVC by writing my own framework, but have recently switched over to CodeIgniter. That being said, either a CodeIgniter specific solution or a general MVC solution will suffice.
Update:
As Ako mentioned below, I could definitely have the events
combined into a single controller and then have the two type
s spawn from that. I am just confused as to how I actually set up each of the controllers (which methods to define, etc.) to make them work together properly.