Re: [PHP Template] Re: [PHP3] template engine example document
[email protected] (Ron Chmara) Mon, 27 Mar 2000 11:32:05 -0700
| Newsgroups | php.template |
|---|---|
| Message-ID | <[email protected]> |
Andrei Zmievski wrote: > > I suppose you could do it that way, or if the designer specifies iteration, they > > could write one include, and have the designer insert 5 includes. > Designers don't control iterations. Not at all. Well, if they can indicate "on the third iteration, use a different bg color for the table cell", they wind up having some iteration influence... > > Here's a counter question. How would your templates allow them to, oh, > > print resuts 12345 as 3151245? > I don't quite understand this question. Perhaps, you could explain? It's a question about what one defines presentation _as_. Most of the trickier PHP problems that template logic would be designed to work with are not clear logic areas, or design areas, but areas where the two *mingle*. If, for example, a database search returns 5 records, 1,2,3,4,5, and the designer wanted them to _appear_ in a different order, with a few repeats, as 3,1,5,1,2,4,5, you now have the raw data component (1-5), and a designer who wants to "present" that data in a specific _order_. They don't want to control the programming of the presentation, they want to control the order they _appear_ in. Basically: Is the sort, the ordering of the data, a designer's perogative or a coder's perogative? Last I gazed through the spec, the template engine would require coder intervention for _every_ sort possibility. And it's not that rare that a designer would say "okay, I want to put a bar on top to allow the users to sort the results by ascending and decending date, author, and the other stuff". > > Do they control *appearance*, or, as this debate goes into syntax > > wars, do they control *syntax* of those variables? > Syntax of the variables? I fear that I fail to grasp your meaning. $phonenumbers[] @phonenumbers They are very similar constructs, *depending on how you parse them*. Both are groups of data, in a list. > > <? include "dbresultcounter.inc" ?><---Result counter for db work, uses > > the count function---> > > There were a total of <? echo $resultcount ?> document(s) found. > > OR > > <? echo $standardhitext ?> <!---This allows for logic to control the > > text varying between was/were hit/hits ---> > Assuming the programmer knows ahead of time that the designer needs > $standardhittext. Otherwise, the designer needs to come back to the > programmer and say, "Give me this variable". Right. The logic must be known, and generated, by somebody. Your templates don't do this *without* PHP code, they use PHP code to generate it.... so many of the template functions are really an intellegent aggregation of pre-built, generalized, logic. OO components, if you will. > > Does your counter-controlled-by-designer-template allow them to > > specify the numbering style? (one, two,1,2,I,II,)? > No, that would need to be done from a PHP script. Because those numbers > are part of the content which the designer does not control. The > designer controls the _presentation_ of that, whether those numbers are > in a table cell or bolded or something else. Again, you are now taking the data _presentation_ away from the designer, or possibly limiting the range of presentation to _only_ HTML formatting. By passing a variable on the numbering *style* to a function, the designer can now present that content in a manner to their liking. > > but the hit you're taking is in evil > > Grep madness, to get the variable tags. > Grep? We're not doing any grep. Hm? I thought your engine was using regular expression replacement. > > Pass the html tags to the general logic, and be done with it. By the time > > you've built all the logic, you have the function, only you don't have > > *all the variables*. By the time you have all the functions available > > in HTML coded into the PHP template-language-parser (<B>, <STRONG>, > > <EMP> to pull into the template parser, you're still lacking the > > _functions_ that designers will want the code to generate, so put > > the tag control back into their hands, and set coders to work on > > the functions themselves. > This is still not clear to me.... In order to put the HTML variables (<BR>,<B>,<Strong>) inside of a a presentation loop, you have to be able to recognize them, or, if you _don't_, you just slam them in there with no validity checking (and guess who gets blamed when the tags break. :-) ) I assumed you were doing validity checking somehow (to make sure your templates didn't have bad tags), but maybe you're just passing it _all_ through. Now, once you have the HTML tags being inserted into the loop points, you're still lacking all the presentation areas that are "fuzzy" areas, areas where presentaion rules dictate some logic. Let's take a search results page for finding web pages, to point out what I mean about the problem of intermingling appearance and logic: "I want to always have the top result in bold" "I want to show the page results by modification date, author, name, etc." "Any results that are outdated, show it in a lighter font color" (See new thread for full challenge) See what happens? The logic of presentaion rules means that they _cannot_ be completely split for complex presentaion of data. And no, for all of these, I don't have a solution to separate them either. Just a way to make it easier. :-) Wanna have another challenge? Get a Shockwave enabled browser, go to: http://www.siegelgale.com, and try to figure out how to make *those* pages as PHP templates. :-) Once the design complexity hits a certain threshold, they _have_ to become part of the coding and logic. This is why a simple template language like PHP became so big, so simple designers could build pages the way they wanted to.... > > Maybe you already have the following document: For each logic > > block, what are the designer vars, and what are the logic vars? > > Can design vars be put into the logic by the designer? Yes? Then > > how? By a new syntax for a $var? :-) > ..as is this. Design vars put into the logic? Yes. Passing tags into the PHP script, so the script can take the tags, and the data, and insert the tags as appropriate. Example: Bold the text in the first column of a table. In order to build that table, a PHP script needs to put that tag in there somehow. The design var (<B>) is inserted into the logic results stream... > > As you make the templates more complex, you rebuild PHP code to handle > > each exception. By focusing on what set of exceptions (coding in loops), > > you're missing the very reason PHP got so big... because, well, when your > > designer says "now, this link makes a PDF", or "this link searches > > LDAP" you now have to again build everything _twice_. Once in PHP, > > and once in your new syntax, to allow the templates to use a new way > > of passing your vars. > Designer is not going to say "this link makes PDF". That's content > again, which is programmer's responsibility. MuWHAHAHAHAHA! Uhm....so now, everytime the content changes, somebody has to bug the programmer? Just like in your negative model, everytime the presentation changed, somebody had to bother a programmer? > > Make an include with all the required components. Pass standard > > variable names. $searchstring gets used an awful lot. :-) Need custom > > variables for a section? Make one include, with all the variables > > for a given section. Let the designers control the page vars, with the > > coders controlling the logic vars. When you need to pass vars between > > the two, do it in a standard manner. > This bit about "passing the vars between the two" is another thing you > might need to explain. Well, it's about a designer having to learn syntax. Whether that syntax is @phone or $phone[] is one part of it, but here's the unfortunate other part (expressed in the proposed template language, but the same problem persists in all coder/designer variable passing): @phone, @phonenum, @phonenumber, @telephone, @telno, @voiceline, @voxline, @voice, @phoneno, @voxnum, @voxno .... The designer has to memorize the right variable and use it consistantly, in order for the coder to do anything with/around/on it. The designer can't just make up the variables whenever/however they want, neither can the coder. In order for the code to interact with the templates, variables have to be passed between the designer, and the coder. Thus, passing the vars. -Bop -- Brought to you from boop!, the dual boot Linux/Win95 Compaq Presario 1625 laptop, currently running RedHat 6.1. Your bopping may vary.