[Zope] Bag 'o newbie questions
Dieter Maurer
dieter@handshake.de
Sat, 10 Aug 2002 16:31:31 +0200
Michael S. Fischer writes:
> 1) We used PHP's "auto_prepend_file" and "auto_append_file" directives
> to paste in a standard header and footer to every HTML document below
> the root. Is there a facility by which we can do this in Zope without
> having each page explicitly call <dtml-var> to render the header and
> footer?
Your options (there may be more):
* You present your objects through a specialized "view" method.
It can add a header and footer as wanted.
Drawback: your URL's must become "<path_to_your_object>/view".
* You role out your own product (you may look at HTMLDocument
for an example)
* You use CMF, maybe in combination with your own product.
Look at the "Document" class (for an example).
* You use dynamic patching to override the "index_html" method
of your objects. You set it to your "view" method above in
the first option.
> ...
> a) <dtml-tree> won't render unless index_html is a DTML method (it won't
> work if index_html is a DTML document)
That should be simple:
Forget about DTML Document. Only use DTML Methods.
> Help me understand the
> namespace issue here: is it not sufficient that a DTML document is
> calling the DTML method that has the <dtml-tree> call?
Read DTML objects in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
> b) I want the <dtml-tree> call to render a tree rooted at / no matter
> which page a user is visiting. I tried encapsulating the <dtml-tree>
> call in a <dtml-with expr="PARENTS[-1]"> as described at
> <http://www.zopelabs.com/cookbook/1003151229> but when I visit
> /a/index_html I see a tree rooted at /a. What am I doing wrong?
Try (untested):
<dtml-let root="PARENTS[-1]">
<dtml-tree root ...>
...
> 3) In directories like /d/dd, where there is no index_html page, I do
> _not_ want to inherit a parent's index_html page; rather, I want to set
> up my own TOC generator for the directory. What's the best way to do
> this?
You put your TOC generator in these folders and call it "index_html".
> 4) I'd like to examine the DTML namespace stack so I can understand it a
> little more deeply. What's the best way to do this?
You can't (at least not easily).
Read "Name lookup" in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
Dieter