[Zope] ZPT help

Albert Chin zope at lists.thewrittenword.com
Thu Aug 28 16:14:02 EDT 2003


On Thu, Aug 28, 2003 at 11:51:41AM -0400, Paul Winkler wrote:
> On Thu, Aug 28, 2003 at 09:14:53AM -0500, Albert Chin wrote:
> > Basic tree structure is:
> >   www.foo.com/
> >   www.foo.com/company-info/
> >   www.foo.com/company-info/contact
> >   www.foo.com/company-info/history
> >   www.foo.com/products/
> >   www.foo.com/products/product-1
> >   www.foo.com/products/product-2
> >   www.foo.com/products/product-3
> >   www.foo.com/projects/project-1
> >   www.foo.com/projects/project-2
> >   www.foo.com/projects/project-3
> > 
> > The "contact" and "history" links appear to the right on the
> > "company-info" page. The "product-1", "product-2", and "product-3"
> > links appear to the right on the "products" page, etc.
> > 
> > The "company-info", "products", and "projects" links would appear
> > across the top.
> > 
> > Is it possible to have one ZPT template which provides dynamic content
> > based on the URL?
> 
> Normally this is done by using acquisition. There's a lot of variants,
> but my favorite ways to solve this kind of problem are 
> 
> ...
> 
> B) use a one-folder-per-page paradigm. This is quite flexible, simple, 
> and should be easy to teach to a content administrator.
> 
> So, assuming the latter, in your root folder, you set up an index_html 
> template that looks a bit like this (simplified):
> 
> <!-- begin template -->
> <div>
>   <!-- common top-nav links go here -->
> </div>
> 
> <div tal:content="structure here/content">
>   The actual page content will be rendered here
> </div>
> 
> <div metal:use-macro="here/right_nav/macros/main">
>   This will be replaced with the right nav macro which you
>   can override per folder.
> </div>
> <!-- end template -->
> 
> 
> Now, create your products and company-info folders.
> In each folder, create a document (can be a ZPT, a DTML
> method, or any other suitable object) called "content".
> This will be the content that gets placed in the middle of the
> index_html in each folder.
> 
> Now create the right nav for the products/ folder.
> To do this, just create a ZPT called products/right_nav.
> It should look something like:
> 
> <!-- begin template -->
> <html>
> <body>
> <div metal:define-macro="main">
>   <a href="/products/product-1"> Product 1 </a>
>   ...
> </div>
> </body>
> </html>
> <!-- end template -->
> 
> Do the same in the company-info folder.
> You'll need a default right_nav in the root folder, too.
> 
> Presto, your framework is done. Now you can create the individual
> leaf pages. To do so, simply:
> 
> 1) create a folder, e.g. products/product-1
> 2) in this folder, create an object named "content"
>
> ...

Thanks. I followed this set up and things are looking good!

-- 
albert chin (china at thewrittenword.com)



More information about the Zope mailing list