Re: [PHP Template] Re: [PHP3] template engine example document

[email protected] (Ron Chmara) Tue, 28 Mar 2000 12:07:27 -0700
Newsgroups php.template
Message-ID <[email protected]>
Andrei Zmievski wrote:
> > 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_.
> I've been sitting here scratching my head and trying to figure out why
> on earth the designer would need to rearrange data coming from database
> like that, and.. well, I couldn't come up with a single example. It
> _might_ be defined as presentation of content, but I can't possibly see
> it being that useful.

Newscasting: What is the lead story of the day? What story is next?
Page layout: What is the most important article?

It comes into play where the designer implements a priority ranking, in cases
where doing it programmatically would be far too complex.

> > 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.
> We're thinking about how to make template engine more extensible so that
> cases like this can be accounted for. One option is to provide some sort
> of macro/mapping file that will map custom commands to PHP functions,
> so that different numbering styles are possible. Another idea is to
> allow embedded PHP for special circumstances, but I'd like to keep PHP
> out of templates, if possible.

??? WHY ???
You are, in effect, rebuilding PHP. As the templates handle more logic, and
become more complex, you are now mirroring PHP functions with the templates,
and they become a different version of PHP. Eventually, as the templates
increase to the same level of function as PHP, you lose the simpplicity
of the template language in the first place....

So why not implement simple PHP functions to start with?

> > 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"
> These are good examples, and some of them would require PHP programmer's
> intervention. But, in our company, for example, the programmer and the
> designer get together when designing an application and determine if
> different sorting/highlighting/whatever will be necessary. Then the
> programmer can provide certain variables to the designer and also do
> some logic for this.

Once again, it is back to _not_ having logic and presentaion separated...

> > 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?
> What does "link this to PDF" have to do with content? If the PDF is
> dynamically generated, then the link will just point to a PHP file.

PDF's are content. Ldap results are content. DB lookups are content.
When the designer's content structuring needs change, the template language
becomes another inhibitor to efficient page building, as the template
language winds up needing an "INSERT MAGIC HERE" tag, or the programmer
and designer wind up resorting to a workflow that is the same as one
without templates, no?

-Bop

--
Brought to you from boop!, the dual boot Linux/Win95 Compaq Presario 1625
laptop, currently running RedHat 6.1. Your bopping may vary.