[ZPT] Page Templates != content.

ethan mindlace fremen mindlace@digicool.com
Mon, 09 Jul 2001 15:00:19 -0400


Lynn Walton wrote:

> Thanks for your input Ethan.  I really do want to make the best architechural decisions I can given time
> constraints, learning curves, etc, so please allow me to ask some more questions regarding what you brought
> up.


Sure.


> So given this, is having the ZPT wrap an XML doc really much different than just having html in a ZPT that
> is only a ZPT so it can call use-macro?


Yes.  If you use Document, from CMF, and "skin" that document with a 
page template, then tomorrow when you decide that all documents need to 
have a new macro slot/define/whatever you can go change it once.  Same 
goes for an XML doc, but there you might have to be more "brutal" in 
your approach.

One (cheezy) way to do this without drinking the CMF kool-aide is to 
have a folder for each "document" with the actual content as an xml doc 
and have it aquire the page template index_html.  Not quite as cool as 
the skins tool but sorta kinda the same thing.


> I can see XML if it's being generated from a database or something, but if it's not, why is html bad?  I'm
> not trying to convince you ... <g> , I want to hear why it's bad?


Mostly because you've defeated the point: by wedding your presentation 
to your content, you set yourself up for a lot of work when either has 
to change drastically.  Like you say, right now it is static but soon it 
will be an application.  Content often starts static, and grows more 
dynamic over time. If you do things "cleanly", then the fact that your 
content object was static and is now a database query shouldn't change 
your presentation at all.


> But say I did have this separate doc ... like an XML or CMF ... can you give me an example of what code
> would look like to make use of it in my use-macro for the master template to get my look and feel?


Well, there's the CMF example - and believe me, skinning a CMFDocument 
is *trivial*. I'm talking 5 minutes work:

http://cmf.zope.org/Members/tseaver/how_tos/taming_types_tool/view

Though I can see that if you're under a tight deadline you may want to 
hold off on the CMF path for right now.

Then there's the other example I gave- folder + index_html + content - 
which is more annoying, but I use in several sites.

Hope that helps,
~ethan