[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] Templates (was: [ale] Need a PHP/MySQL intern...)


Thanks for the explanation.  I understand how this
could make life easier on a larger scale project where
the programmer is separate from the designer (I play
both roles).  I also understand the benefit of having
a page contain only valid html.  However, your
scenario still doesn't prove any real benefit to me
over PHP.

As a designer, I could develop an entire site in pure
HTML (as in your example).  Then, wearing my
programmer hat, I go through the code and insert the
various PHP code where necessary, just as your
programmer would go through a template any insert the
necessary AVPs.

To extend your example, we have the code:
This is the introduction paragraph from the WhizBang
web site.
The programmer modifies it thus:


I guess the problem with the above example is that
there is no default value in the <p> tags after the
PHP is inserted.  Hmm...ok, maybe seeing a bit more of
the forest now.  See if this is an accurate summary of

1.  Abstraction of code from those clueless *design*
people ;-).

2.  Everything represented as valid HTML tags.

3.  The ability to provide default values for a
particular html block, and have these display without
any special preprocessing.  If a particular AVP is
defined, the block will be replaced by the eval of
whatever code is contained in the AVP.

I definitely see benefit in number 3 and understand
why you would want to implement it in that way. 
Changes can be made and tested to the *design* without
even having to reside in a preprocessing enabled web

Now, consider the following example from Smarty (taken
from the Smarty QuickStart at

Hello, {$Name}!<br>
{$FirstName}, {$LastName}<br>
{$Address}, {$Zipcode}

Each {} (these delimeters can be changed) block is
evaluated as php.  The variables are tied to actual
php variables or constants from bus logic by the
developer in a separate file.  

This is what was confusing me.  Why do this at all? 
Why couldn't this simply be done in straight PHP? 
It's not providing valid html tags...it's not
providing default values, although if you leave the
delimeters as they are it will in the very least show
up in a WYSIWYG (on the Smarty site they recommend
changing the delimiter to something like <!--: :--> so
it *won't* show up in the WYSIWYG).

It would seem the same could be accomplished by
straight php:

Set the vars somewhere where they are accessible, and

Hello, <?=$Name?>!<br>
<?=$FirstName?>, <?=$LastName?><br>
<?=$Address?>, <?=$Zipcode?>

Does the same as far as I'm concerned.  Maybe it looks
a bit scarier to non-programmers?  I don't know.

Sorry to run on, but I know the Smarty
developersdidn't put a lot of work into their code for
nothing.  There has to be something I'm
missing...template use in widespread, so there has to
be some real benefit.

Still waiting for that !aha! ;-).


--- Joseph A Knapka <jknapka at earthlink.net> wrote:
> jb wrote:
> > 
> > Ok...educate me here please.
> > 
> > I'm not sure I see any real benefit of using
> templates aside from making
> > your code look a bit prettier for someone who
> might be php illiterate or
> > terrified of non-html source.  Looking at Smarty
> for an example, it
> > would seem that all (and forgive me if I'm
> wrong...this after a cursory
> > look ;-)) it provides is merely another layer of
> abstraction on top of
> > php...function calls that look different from
> actual function calls but
> > are still function calls...if/then/elses and loops
> likewise.
> > 
> > Where's the benefit? As far as being able to
> affect all pages on a site
> > with a single line change, can't you do this by
> including a general file
> > that would set a var like $background, or
> $fontcolor, etc.?  As far as
> > separating presentation from business logic, can't
> this be accomplished
> > by function calls or objects (i.e., have a set of
> function libs or
> > classes specifically to handle bus. logic, and
> have your display code
> > make calls to these resources)?
> That is easier said than done.
> > Is Zope in someway different?
> I don't know anything about Smarty (or PHP, for that
> matter),
> but the advantage of page templates (as implemented
> in Zope,
> anyway) is this: a web designer (that is, a
> graphic-artist-wysiwyg-what-the-heck-is-code?
> type of person) can lay out every page on the site,
> in the
> HTML design tool of her choice, including "typical"
> sample
> content. The pages, designed in this way, are 100%
> functional
> static HTML pages, with no logic behind them. They
> can be used
> to demo the site, validate usability to some extent,
> and so
> forth.
> A programmer can then implement all the site logic
> by adding
> namespaced ZPT attributes to the HTML code. The
> resulting pages
> are *still* 100% functional static HTML, and can
> still be
> edited by the page designer's WYSIWYG HTML tool -
> but when
> served by Zope the ZPT attributes cause the sample
> content
> to be replaced by the output of whatever business
> logic
> the programmer has implemented.
> For example, the page designer writes:
> <P>
> This is the introduction paragraph from the WhizBang
> web site.
> </P>
> The programmer modifies it thus:
> <P tal:content="python:getIntroText()">
> This is a sample paragraph from the WhizBang web
> site.
> </P>
> The tal:content attribute causes Zope to replace the
> contents of the <P> tag with the output of the
> "getIntroText()" function call when serving the
> page,
> so that what the client sees is something like,
> <P>
> Welcome to WhizBang Industries! We rule! Give us
> your money!
> </P>
> All of ZPT works this way, and the result is that
> designers do what they do best, programmers do what
> they do best, and they don't have to deal with each
> other's stuff (much).
> This is different than schemes like DTML (Zope's
> "old" templating language) and apparently PHP (from
> the few samples of PHP code I've seen), in that
> ZPT code is always also valid HTML, and thus can be
> viewed and edited in raw form by most HTML design
> tools. DTML and PHP muck up the page with
> nonstandard
> tags which normal HTML editors have to (1) ignore,
> (2) choke on, or (3) be taught how to handle.
> Further,
> DTML and PHP tangle logic irretrievably up with
> presentation, so that designers must become
> programmers
> and vice versa in order to get any work done.
> Cheers,
> -- Joe
>   Using open-source software: free.
>   Pissing Bill Gates off: priceless.
> ---
> This message has been sent through the ALE general
> discussion list.
> See http://www.ale.org/mailing-lists.shtml for more
> info. Problems should be 
> sent to listmaster at ale dot org.

Do You Yahoo!?
Yahoo! Sports - live college hoops coverage

This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.