Presentation is loading. Please wait.

Presentation is loading. Please wait.

EIONET Training Zope Page Templates Miruna Bădescu Finsiel Romania Copenhagen, 28 October 2003.

Similar presentations


Presentation on theme: "EIONET Training Zope Page Templates Miruna Bădescu Finsiel Romania Copenhagen, 28 October 2003."— Presentation transcript:

1 EIONET Training Zope Page Templates Miruna Bădescu Finsiel Romania Copenhagen, 28 October 2003

2 Concepts n ZPT - Zope Page Templates are a web page generation tool n The TAL - Template Attribute Language is an attribute language used to create dynamic templates n METAL - Macro Expansion TAL is a macro language built into the ZPT system Macros are a way to share chunks of presentation, and have the shared stuff appear inline in the template – Evan Simpson n The TALES - Template Attribute Language Expression Syntax standard describes expressions that supply TAL and METAL with data

3 Zope Page Templates aim n Play nicely with editing tools. n What you see is very similarly with what you get. n Keep code out of templates, except for structural logic. n It is a valid HTML page outside/inside Zope. Allow designers and programmers to work together easily. n Dynamically renders XML as well as HTML n It is deliberately not as powerful and general-purpose as it could be. It is meant to be used inside Zope in which other objects handle business logic and the tasks unrelated to the page layout.

4 Page Templates vs. DTML n DTML is not aimed at HTML designers. n A page with DTML code into it, becomes invalid HTML outside Zope. n DTML suffers from a failure to separate presentation, logic, and content (data). n DTML can do things that Page Templates can't (e.g. dynamically generate email messages ) n DTML is enough easy script language to do simple scripts for simple sites n DTML adds too much magic to object lookup without allowing enough control

5 Replacing DTML with ZPT n DTML: ZPT: Page Title - here resolves to the object to which the template is applied - tal:content attribute is a TAL statement that set the text contained by the title tag, and the value "here/title" is an expression providing the text to insert into the tag. n DTML: ">contact ZPT: contact - tal:attributes replaces the value of an attribute or create a new one with dynamic value; string evaluates a TALES string expression

6 Replacing DTML with ZPT n DTML: ZPT: request info - tal:replace attribute is a TAL statement that replace the content of an element and removes the element leaving the content; structure – the value it is not html encoded n DTML: ZPT : - tal:condition conditionally inserts or removes an element - python executes a python expression

7 Replacing DTML with ZPT n DTML: ZPT: - tal:repeat replicates a sub-tree of your document once for each item in a sequence; the expression should evaluate to a sequence - tal:define defines variables (local variables are default)

8 Using Macros n You can define macros with tag attributes similarly to TAL statement Last updated If you change the macro then all page templates that use the macro will automatically reflect the change. You can use macros from other page templates by referring to them through the macros attribute of the page template in which they are defined. Macro goes here - metal:define-macro -- macro is identified by a path expression using this statement - metal:use-macro – replace the statement element with named macro

9 Using Slots n Common use of slot is to provide default presentation which you can customize n In the following example, the slot definition is just an empty span element n You can fill the slot with any html code you want, for example : Info


Download ppt "EIONET Training Zope Page Templates Miruna Bădescu Finsiel Romania Copenhagen, 28 October 2003."

Similar presentations


Ads by Google