Welcome Guest, Not a member yet? Register   Sign In
The correct way to use and structure controllers.. etc.?
#3

[eluser]jedd[/eluser]
Correct. Gallery becomes a controller, and the first segment in your URL as a consequence.

You don't do this so much for the URL format -- you can work around your '/main/gallery/' problem, above, using routes -- but simply because a controller should typically concern itself with a single resource (or 'thing', if you prefer) within your system. Plus you don't want it getting too huge, just for the sake of manageability and, maybe, performance.

You'd also have one or more models that this controller talks to. The way I would do it would be to have a controller called Gallery, and a model called Picture or Image or Photo (etc - basically a synonym) that manages all the data storage and retrieval aspects for your images. The data you're managing in this case is likely to be a hybrid of several database tables, and a hierarchy in your file system somewhere to actually store the pictures.

Note there are, broadly speaking, two other common approaches to this.

First, have a model per table in your database (and possibly one more dedicated to managing the file system aspects) and your Gallery controller deals with all the involved models.

Second, have a model, much as I describe above, but called Gallery_model. (Personally I think that's the worst, but some people seem to enjoy it.)


Messages In This Thread
The correct way to use and structure controllers.. etc.? - by El Forum - 09-27-2009, 02:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB