Getting fairly familiarized with namespaces and acquisition is going to be
useful here.

You actually will need to do 2 templates (one for the footer, and one for
the header) in the case of writing a "wrapper."   That said, objects in Zope
(like a document, in this case) behave based upon their context or
environment.  A DTML document, when it is told to render something with
<dtml-var name="foo"> looks for foo in it's current namespace (i.e. the
folder it is in), and if it doesn't find it, it then works its way upward
(by looking in the namespace of the folder that is the parent of the folder
it just looked in before).  When it finds foo, it renders that method (or if
foo is an attribute, it renders its value).  

Let us suppose that your document is called bar, and looks like this:
 <dtml-var name="foo">

bar is in a folder hierarchy that looks like this (using URL syntax)

bar would first look for foo as an attribute of it's own namespace (i.e. it
would look to see if you defined a custom property called foo in the
properties of the document).  If it found it, it would render it, but let's
suppose that it does not find it, so it has to look in another namespace.

So, it moves up to the next namespace (subfolder) looking for foo, as either
a method of that folder or a data member (attribute).  If it finds it, it
renders it.  If not, it moves up to folder1 as the next namespace, and
perhaps that is where it finds foo; in that case it renders foo.  Seems
rather simple, and in some cases it is, but what if foo is a dtml method and
looks like the following?

<h1>Title:<dtml-var title></h1>

Where does foo look for title? Not in folder1, where foo resides, but in in
bar's namespace, and indeed, since dtml documents have a title attribute,
that will be rendered.  If, instead of title, we had an attribute named
something like "what" but there was no attribute named "what" in bar, it
would look through the namespace stack (starting with the namespaces of bar,
then subfolder then folder1, then the root folder, etc), until it found what
it was looking for.

This, I hope, explains acquisition well.  If you were to apply this to
templating strategies, you would realize, that (as long as you kept
standard_html_header and standard_html_footer in sync) that you could do
some powerful things with your site navigation.  Consider the following

Suppose you have a sports news site, and you publish stories about baseball,
football, and basketball.  In the upper right hand-corner of your document
(i.e. in the header portion) you have an 32x32 icon image that is a picture
of a football, basketball, and baseball, respectively.  Otherwise, you
wanted to use the same template for all of the documents.  

Suppose that you have a folder structure like this:

In this case, you could have a standard_html_header in the root folder /
that creates the top portion of your document, so you only have to use one
template, and that the template might have code that looks like this:

<!--html here-->
<dtml-var name="sports-icon.gif">
<!--more html here-->

In this case, you could have an image in each folder (basketball, football,
baseball) containing an appropriate image with the id of sports-icon.gif.
This is useful, because now, one template is rendering sports news stories
different folders differently, depending upon the context of the folder they
are contained in.  

In this simple example, you don't even need to create a different
standard_html_header for every folder to create different results, but can
rely upon Zope's built-in acquisition smarts to work for you.  Applying this
in practice, takes some playing around with, but once you get a clear idea
of applying this, you can create some very intelligent standard_html_headers
that do a lot of work for you.

Hope this helps,


-----Original Message-----
From: Nuno Goncalves [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 14, 2000 10:19 AM
To: Oleg Broytmann
Cc: Max M; Zope@Zope. Org
Subject: RE: [Zope] site structure (fwd)

> > But how could you build a page with the template developed ??
> > something like:
> > and how can you generelize the objects to beeing used by the template ?
>    No, no, no! :)
>    You misunderstand how the Zope works. You think that basic building
> block is a piece of HTML (probably you think to put it into DTML
> Documents). No. In Zope basic building block is "instance of some python
> class". A DTML Document is an instance of DTMLDocument class, e.g.
>    If you develop your own set of classes, you'll just build Zope sites
> creating instances of these classes - you put HTML fragmenst just into
> these instances. Zope will call your objects, you don't need to use DTML
> call them.

humm !!! I see now !!
So i can have a general structure for all my site and when create a
page, specifying the template to use and consequently adding the objects
that i want ??


> Oleg.
> ----
>      Oleg Broytmann     [EMAIL PROTECTED]
>            Programmers don't die, they just GOSUB without RETURN.

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to