[Zope] Use Page Template to emulate standard_html_footer and header

Peter Bengtsson mail@peterbe.com
Thu, 21 Feb 2002 22:15:55 +0100


--- standard_html_header Python Script ---------

page = context.standardlook()
return page[:page.find('<!--METALbody-->')]

------------------------------------------------------------------

--- standard_html_footer Python Script ---------

page = context.standardlook()
return page[page.find('<!--METALbody-->')+len('<!--METALbody-->')+1:]

------------------------------------------------------------------


---- standardlook Page Template-------------------

<html metal:define-macro="standard">
... bla bla...
    <div metal:define-slot="body">

<!--METALbody-->

    </div>
... bla bla...
</html>

---------------------------------------------------------------

The sad thing about this approach is that you have to invoke the macro 
template twice, but it lets you have the odd few DTML methods in a 
ZPT'ified structure.


Cheers, Peter

At 11:26 2002-02-21 +0100, Robin Smidsrod wrote:
>Is there a way to split up a page template, and define
>both standard_html_header and footer as page templates which use the other
>template. I've tried the <metal:block define-macro="header"> and
>relevant for footer, which should kindof work, but when I try to
>save the master template it says that some of my tags aren't
>nested correctly. This kindof makes sense, because I break the nesting to
>be able to get the "header" of the template.
>
>The reason I would like to now this is because I have some
>DTML documents which need the standard_html_header, and it would be boring
>to have to duplicate the work I've done in the template into another
>DTML-document.
>
>Any help appreciated...
>
>-- Robin
>
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )