[Zope] MetaHeaders in Zope
Terrel Shumway
tshumway@epicor.com
Sat, 25 Sep 1999 13:19:34 -0700
From: jonathon [mailto:jblake@stamp-coin.com]
Is there a way to have the header data that changes for
each page, somehow be incorporated into a one tag ---
like the the current <!--#var standard_html_header -->
would be the same on each page? If so, how would I
do it? Going through the docs I don't see any mention
of this "problem".
I think that the docs don't mention this specifically because it is exactly
what Zope does very well and very easily: Acquisition is the key.
Here is one way that I might do it:
/standard_html_header:
------------------
<html>
<head>
<title>
<dtml-var title_or_id>
</title>
<dtml-var dynamic_headers>
<dtml-var static_headers>
<dtml-var stylesheet>
</head>
<body>
-------------------
/static_headers:
-------------------
< whatever ...>
-------------------
/dynamic_headers:
-------------------
<!-- empty (or default): just so Zope doesn't choke if there is nothing else
defined later --->
-------------------
/layout:
-------------------
<dtml-var standard_html_header>
<dtml-var navigation>
<dtml-var content>
<dtml-var standard_html_footer>
/index_html: (I define this DTML Method once, and never create any others
higher up)
-------------------
<dtml-var layout>
-------------------
Then, my default document in any subfolder is a DTML Document "content".
I could define a DMTL Method "dynamic_headers" that would build the headers
from the properties of "content", or
I could simply have it contain the required text.
If i want per-document headers (instead of per-folder headers) I could say:
/.../foo/bar:
-------------------
<dtml-let
title = "bar_content.title"
content="bar_content"
dynamic_headers=" whatever expression you want that will build your
headers "
>
<dtml-var layout>
</dtml-let>
-------------------
/.../foo/bar_content must be a DTML Document ( not a DTML Method )
If I define "dynamic_headers" as a DTML Method that uses the properties of
"content",
I can completely omit the dynamic_headers in the <dtml-let>.
1 user says: GET /.../foo/bar
2 dtml-let: content=bar_content, title = bar_content.title
3 layout calls standard_html_header
4 standard_html_header sees "/.../foo/bar_content.title" as the title
5 standard_html_header calls dynamic_headers
6 dynamic_headers builds the headers from properties of
"/.../foo/bar_content"
...
layout includes "content" from "/.../foo/bar_content"