[Zope] Kube and ZPT
Tom Nixon
tom.nixon@aim23.com
Tue, 12 Mar 2002 10:17:06 -0000
I solved this with a bit of a dirty hack that's not ideal but does the
job for the time being until I work something better out. I thought I'd
share it with the list for the benefit of the archive.
1) For each folder that you want to redirect, add a String property
called "redirect" and give it a value equal to the name of the Kube you
want it to redirect to. So The WhoWeAre folder has a redirect property
value of "CompanyInfo".
2) Create a python script called redirect.py containing the following
code:
return "<script>window.location = '%s/%s';</script>" %
(context.absolute_url(), context.redirect)
4) Add the following code somewhere near the top of index_html:
<div tal:define="doctype here/meta_type"
tal:condition="python: doctype != 'Kube'"
tal:replace="structure here/redirect.py">Redirect URL</div>
5) Put the rest of the Template code inside a div tag like this:
<div tal:define="doctype here/meta_type"
tal:condition="python: doctype == 'Kube'">
:
:
</div>
So now when index_html gets called with the context of a folder, it
redirects to the Kube specified in the redirect property of the folder.
If it gets called with the context of a Kube then it renders normally.
It works, but it's not good practice to rely on a JavaScript redirect
for basic navigation. Not a problem if you're running it on an Intranet
where you know the broswers can handle it, but not advisable for public
web sites.
T.
> Has anyone on the list been using the Kube product?
>
> I have built a simple site using folders for the main site
> areas and Kubes to hold the document content.
>
> The structure looks like this:
>
> Root
> |- index_html (Page Template)
> |- WhoWeAre (Folder)
> | |- CompanyInfo (Kube)
> | '- People (Kube)
> '- WhatWeDo (Folder)
> |- Products (Kube)
> '- Services (Kube)
>
> If I call http://zopeserver/WhoWeAre/CompanyInfo the
> index_html template is rendered using content from the
> CompanyInfo Kube - Great. BUT...
>
> When Someone calls http://zopeserver/WhoWeAre I would like it
> to default to the CompanyInfo Kube. I cannot create an
> index_html inside the WhoWeAre folder because we need it to
> acquire index_html from the root for presentation. I also
> thought about making WhoWeAre into a Kube which contains the
> other Kubes but this seems wrong to me because WhoWeAre is
> part of the site structure, and not content in its own right.
>
> Can anyone suggest anything else?