Re: [PHP3] template engine example document
[email protected] (Monte Ohrt) Sat, 25 Mar 2000 10:26:05 -0600
| Newsgroups | php.template |
|---|---|
| Organization | ispi |
| Message-ID | <[email protected]> |
Hi Ron, Ron Chmara wrote: > > Monte Ohrt wrote: > > Ron Chmara wrote: > > > So, the programmer sticks the logic in an include (or require), the HTML folks > > > assign values to the variables....the coders mess with the logic, not the html, > > > the html folks mess with the HTML (as needed). > > > What's missing from this? > > > -Bop > > With your method, the programmer must change the PHP logic (what is > > included) for each template. > > Not at all. There is no limit to how many HTML pages can call the same logic > block. If the logic _features_ change, then in both of our methods, the > programmers have to rework the pages. I'll give you an example: The server- > wide credit card validation logic is one, and only one, file. It never > has to be duplicated, never seen by the website designers. The most a > designer has to do is add an hidden form variable, or build an HREF on > a page, (both are things they're fairly knowledgeable about) and on > the next page, know the syntax for an include, and decide > where to put the result. So adding dynamic content means they need to > know all of *two* statements. Sometimes there are logic changes that only affect presentation, not content. For example, in one template the rows alternate colors, on another template they do not. For another example, you want a <BR> tag in front and in back of the title, unless the title is blank, then print one <BR> only. Then in another template, you want NO <BR> tag if there is no title. How is this taken care of with the same logic, different templates? > > > The way we proposed to make this work: the programmer passes content to > > the template, the designer controls the presentation of this content, > > and they control ONLY the presentation. The small set of functionality > > in the template spec accomplishes just that. > > This would mean that my designers do, indeed, have to know the following > (and they do): > > Logic: > <? include "generic_logic.inc" ?> > > Presentation: > <? echo $var ?> See the examples I gave above. > > Hey, Rasmus/Zeev et al: Can we get a variable function equivalent > to echo? As in: > <? #$var ?> > being the same as: > <? echo $var ?> > > > The designer can make > > templates to their hearts desire without the need to change the PHP code > > underneath. > > Exactly. They don't even need to learn a whole new language, beyond > an include, and, maybe, an echo. > > > Then later if you want to update the PHP code, there is only > > one set of code to update, not a whole slew of differing PHP code for > > each template. > > So don't build different code for each web page! That doesn't require > a new syntax, that requires building generalized logic. We are rapidly > spiralling from the newish template debate into the old monolithic vs. > OO debate... and your code is basically _an_ OO set of generalized > logic, which, for some reason, you are passing using an new syntax. > > -Bop Well as in the examples I gave above, I'd like to know how these situations can be handled through "generalized logic" that the designer does not see. There are other situations with looping content too. And thanks for your constructive input, this helps alot! Monte