From: Furbo <fu...@si...> - 2003-08-28 18:44:09
|
to start a new thread for this topic (so it doesnt continue in the file and db prefix messages) My views of templates... A template should be just that, a template for layout and the gui of something. No, conditions, loops, or logic INSIDE the template. That is what code (php or other) is for. Templates are supposed to be a separation of logic from presentation. I know smarty offers these Programming constructs but this should be avoided. As to ideas for subtemplates.. SURE, if fact in a way a subtemplate would have to be used to create a simple table of result output.. one template for the overall table, one for the formatting of a row. as for a template controllin what gets loaded, aka a TRUE sub-template implementation one must look at the processing of templates. Does the code do its thing and then load the template for display? or does the code load the template first to see what SHOULd be displayed and only process that? two completely different ways of looking at template use, both offering same features and general same results but offering drastically different options, implementations, and performance (somewhat) 1) Code does its logic then calls a template for layout: with this approach all the logic of a module is done, selects, processing, math, whatever.. then variables are built and passed to the template engine.. at that time the engine swaps out the Variables from the actual template file with the values from the code.. Pro have to know ahead of time what is to be loaded into the template. Much easier to handle templates Con all logic for a module is run, even if the final layout template will not use it 2) code loads template then only processes logic that is has to: this approach loads the template first and lets it truly control not only what is displayed where, but what needs to be processed.. If the layout did not need a piece of info, the module would never load it. This also allows for the dynamic calling of a subtemplate or submodule (possibly) and the template engine will load it. pro only the logic from a module that is actually used is called.. No extra processing Con have to parse the template first to see what Variables are needed.. then perform the logic, then swap the variables back into the layout These are 2 approaches to doing templates both get same results just one is more flexible (2) than the other.. BUT #2 is much harder to create. -- Furbo Computers are useless. They can only give you answers. -Pablo Picasso |