MVC, HTML, and JSON - what goes where?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

kyberfabrikken wrote:A template is not the only technique, for rendering output (Depending of course on, what you put in the name 'Template').
My thought was that while a View may use a Template for rendering, a Template does not use or know anything about Views. I think of the Template pattern as being more primitive than the View. A Template does some kind of transform, whereas a View is a higher level assembler of all or part of the presentation.
(#10850)
User avatar
kyberfabrikken
Forum Commoner
Posts: 84
Joined: Tue Jul 20, 2004 10:27 am

Post by kyberfabrikken »

arborint wrote:My thought was that while a View may use a Template for rendering, a Template does not use or know anything about Views. I think of the Template pattern as being more primitive than the View. A Template does some kind of transform, whereas a View is a higher level assembler of all or part of the presentation.
I suppose it depends on, what you mean by "a view". In my mind, a view component, is some sort of command object, which returns a string value. There are different implementations, but they all share the same interface; Primitive templates are views, as are reusable implementations (aka widgets). Then you have application specific implementations, which would normally handle a specific request (What you call "a view") -- These would normally be composites of the primitive kinds of views. While the latter kinds are more specific, I don't see any reason to treat them as being different from the primitive ones.
Last edited by kyberfabrikken on Fri May 18, 2007 2:08 am, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I think of "a View' as being part of "the View", by which I mean the part of the Presentation layer responsible for creating the ouput/response. A View can return a string, but it could also return a Value Object for the Response to use, or it could simply echo its output. I think of a a View as having a different interface that a Template. Views may need to do things like load Models or access the Request. A Template's interface is pretty much set, render and transform controls. Sometimes all the View needs to do is a transform -- those are the cases where the View can be a Template.
(#10850)
Post Reply