quick search:
 

How DTML and ZPT can share a standard template

Submitted by: magnus
Last Edited: 2001-08-10

Category: PageTemplates

Average rating is: 5.0 out of 5 (2 ratings)

Description:
If you are using Zope Page Templates (ZPT) you don't have a standard_html_header and standard_html_footer. Some old products still rely on having these (Suishdot is one example).

This example shows how to solve this problem using two small python scripts.


Source (Text):
ZPT-file StandardTemplate:

<html metal:define-macro="master">
  <head>
    <title tal:content="template/title">The title</title>
  </head>
  <body>
    <span metal:define-slot="content">
      <!---dtml--->
    </span>
  </body>
</html>



Python script standard_html_header:

import string
page = context.StandardTemplate()
return page[:string.find(page, '<!---dtml--->')]



Python script standard_html_footer:

import string
page = context.StandardTemplate()
return page[string.find(page, '<!---dtml--->')+14:]



ZPT-file zpt.html:

<html metal:use-macro="here/StandardTemplate/macros/master">
  <head>
    <title tal:content="template/title">The title</title>
  </head>
  <body>
    <span metal:fill-slot="content">
      foobar
    </span>
  </body>
</html>



DTML-file dtml.html:

<dtml-var standard_html_header>
  foobar
<dtml-var standard_html_footer>

Explanation:
Not the best of solutions, but it does work...

Comments:

No Comments