On Sunday, June 2, 2002, at 08:36 AM, Page Page wrote:
I like page templates because they permit uncomplicated cooperation with designers who don't know DTML and/or use drag-and-drop composers. Newbie I am, however, I see a few problems here, and I hope they stem from my ignorance.
1.) Can page templates be "modularized"? DTML is great for assembling pages from re-usable blocks, i.e. dtml_standard_header, dtml_standard_footer. I have not found an equivalent facility for page templates. Is there any?
METAL, one of the three components of ZPT <dtml-var standard_html_header> <dtml-var "banner_ad('car_ad')"> My content </dtml-var standard_html_footer> becomes <html metal:use-macro="here/standard_template.pt/macros/page> <body> <div tal:replace="python: here.banner_ad('car_ad')">Banner Ad</div> <div metal:fill-slot="body"> My content </div> </body> </html> And if you need to mix DTML and ZPT, your standard_template.pt can even use your existing standard_html_header and standard_html_footer (but this is probably defeating the purpose of using ZPT anyway...)
2.) Symbols How am I supposed to work with symbolic information like table width? Of course, I'm free to create python-functions which pull the raw figures from a config-file or db, but having a separate function for each of the dozens of symbols I would need will give me carpal tunnel syndrome.
Exactly the same way you already do in DTML if you want. <table width="<dtml-var global_tab_width>">...</table> becomes <table tal:attributes="width here/global_tab_width">...</table>
3.) Dynamic pages This is a more generic newbie question, since it is not confined to the realms of page templates. Let's say my site sports a uniform layout for hundreds of used-car ads. Each ad gets its own page which content is pulled from a data-base on the fly. This content is wrapped into identical hooks for banner ads, a header, footer and navigation bar. Without Zope one sets up a table of content with a link to each ad; each link calls a cgi-script with some id for the data-base in the QUERY_STRING. This requires the script to assemble the page, send the cgi-ahoy (content-type: text/blabla) and the <html> for the page. Is there a Zope-ish way to do this? I have not even found a way to access a page template from a script for reading. The data for Zope-objects seems to be pickled in files.db.
This could be done with four methods: 2 x ZSQL methods, one generating a list of ad ids for your table of contents, another one returning the contents for a specific ad. 2 x ZPT pages, one rendering the list of ads using a tal:repeat, and the other one rendering a single ad. If these two share a common look and feel, you would also have a third ZPT document (standard_template.pt, or whatever you want to call it). You can also avoid using an external database entirely if you like, storing your ad contents in ZODB instead (this is the most Zopeish method I guess). -- Stuart Bishop <zen@shangri-la.dropbear.id.au> http://shangri-la.dropbear.id.au/