Welcome Guest, Not a member yet? Register   Sign In
How to Best Structure App Controllers ?
#1

[eluser]Unknown[/eluser]
I'm building my first CodeIgniter app, and while I'm mostly getting the syntax, I'm having trouble figuring out the best way to set the controllers up. It seems like a very typical app, so I'm hoping there's a standard way this kind of thing is done. Any help would be much appreciated!

The app is a way for me (web designer) to present rounds of designs to my clients. The designs are organized in the following structure:
Client > Project > Set > Item

For example,
Alchemy Goods > Website redesign > Wireframes, round 2 > Contact page wireframe
Seattle Public Library > Rebranding > Mood boards > Mood board A

Think it's set up similar to songs in iTunes:
Genre > Artist > Album > Song

So, the user starts at the most broad level and drills down through each level to reach a specific at the end. And, each step down the chain is both a detail and a list. The client level is both a detail of a specific client and a list of projects. The next level is both a detail of a specific project and a list of sets. This situation is making me really confused about how to set up the controllers.

Currently, I see two options:

(1)
- Main controller lists all the clients
- Clients controller lists all the projects of a specific client
- Projects controller lists all the sets of a specific project
- Sets controller lists all the items of a specific set
- Items controller shows the detail of specific item

(2)
- Clients controller lists all the clients
- Projects controller lists all the projects of a specific client
- Sets controller lists all the sets of a specific project
- Items controller lists all the items of a specific set
- Items controller also shows the detail of specific item

Neither seem totally right to me, so maybe I'm missing another option entirely.

Anyone have any thoughts? How would you set something like this up?

Thanks, Scott
#2

[eluser]sikko[/eluser]
According to me, the best solution is by far the second one.
It seems more "obvious" for the "Project" controller to retrieve "Project" items.
By the way, each controller should call its own model.
So you'd have "Project" controller which calls "project_model" which has all the methods that you need to retrieve one or more "Project" from the database.
#3

[eluser]Unknown[/eluser]
Thanks sikko. That's helpful




Theme © iAndrew 2016 - Forum software by © MyBB