Search code examples
model-view-controllerdesign-patternscfwheels

Static pages in MVC framework?


Where do you guys put your static pages, like "home", in an MVC framework? Do you have a "home" controller? A "pages" controller? Do you create actions for each static page?

I'm using CFWheels now, and I'm trying to figure out the best place to put them.


Edit: Apparently CFWheels doesn't require you to create actions for all your views. So you can just create an empty controller and call the views like actions, but not have to write out the blank functions.


Solution

  • At the end of the day, a static page is a view without a model, that was returned based on an action the user requested from your server by hitting particular route. :-)

    Yes, technically you could expose the direct location of the view resource to the user and rely on the http daemon to go fetch it and return it. However, that means that the resource URL is now tied not to the semantic of the resource you want to expose, but to actual bits. This means that if you want another representation of that same resource, you have to expose it on a different URL.

    So, when you create the structure of your web app, think first about the URLs and the resources you want to expose and then think how to implement each resource.