[Zope] Problems creating auto-navigation links (LONG)

Dan Shafer dan@gui.com
Wed, 12 Sep 2001 21:40:11 -0700


I am having a lot of problems trying to get a breadcrumb or tree or 
other page-by-page, automatically generated navigational scheme put 
into place on my Zope site. I have a sense that I may be trying too 
hard or that I've created some complexity here that I didn't need to 
(or that my ISP has done so).

This question is necessarily long because I want to provide as much 
detail as possible. Forgive me for the length of my post. Brevity is 
the soul of wit but not of Zope apprentices (Zoprentices?).

Here's the basic structure of the site:

1. I have a Zope instance (Version 2.3.3). It is hosted by David 
Elkins at hurrah.com. He seems to be a very knowledgeable Zopista.

2. He has implemented virtual hosting for me because I need to host 
lots of sites at this instance.

3. One of those virtual sites is www.danshafer.com, which site lives 
in a folder called danshafer at the root level of the Zope instance.

4. Inside danshafer, I have a folder called OMO. It is strictly a 
container; it doesn't have a public interface at all.

5. Inside danshafer.com/OMO, I have a number of other folders, one of 
which (by way of example) is named omoarts.

6. Inside these folders are DTML documents containing essays.

OK, so that's how it's structured.

My objective is to define a DTML method (presumably) which will be 
set up so that when the user is reading an essay called 
writingadvice.html and titled "Advice I Offer Aspiring Writers," 
there will be a navigation line across the top of the essay page that 
links him back to omoarts/index.html (by title) and to the top level 
of the danshafer.com site.

The first efforts I made at this had bizarre results. Depending on 
how I navigate around, I get URLs like this:

http://www.danshafer.com/danshafer/danshafer/OMO/omoarts/writingadvice.html

Sometimes I get as many as three or four spurious "danshafer" entries 
in the URL. I have no clue how this happens.

This was using an NFGNav object. The link at the top of the page, 
intriguingly, shows _only_ the top-level page in the danshafer site. 
Here's the DTML I place on the page, per the example in the NFGNav 
docs:

<p>
<dtml-var "DSNavigator.LevelTrail(
	PARENTS,
	REQUEST,
	id(),
	initlevel=1,
	Meta_Types=['DTML Document','Folder'])">
</p>

So I try the simple breadcrumb DTML I got from the Zope How-Tos. 
Here's what it looks like:

<!-- Start Breadcrumbs -->
<dtml-unless expr="PARENTS[0]==PARENTS[-1]">
<dtml-call "REQUEST.set('reverse_PARENTS', [])">
<dtml-call "REQUEST.set('reverse_LAST', 0)">
<dtml-in PARENTS skip_unauthorized>
<dtml-if expr="(meta_type == 'Message') or (meta_type == 'Reply')">
<dtml-unless "reverse_LAST==1">
<dtml-call "reverse_PARENTS.insert(0, _['sequence-item'])">
<dtml-call "REQUEST.set('reverse_LAST', 1)">
</dtml-unless>
<dtml-else>
<dtml-call "reverse_PARENTS.insert(0, _['sequence-item'])">
</dtml-if>
</dtml-in>
<dtml-in reverse_PARENTS>
<dtml-if sequence-start><a href="/">Home</a>
<dtml-else>
<dtml-if sequence-end>
<dtml-unless expr="(meta_type == 'Message') or (meta_type == 'Reply')">
&gt;&nbsp;<font size="+1" color="#990000"><b><dtml-var title_or_id></b></font>
</dtml-unless>
<dtml-else>
<dtml-if expr="(meta_type == 'Message') or (meta_type == 'Reply')">
&gt;&nbsp;<a href="<dtml-var absolute_url>"><dtml-var title_or_id></a>
<dtml-else>
&gt;&nbsp;<a href="<dtml-var absolute_url>"><dtml-var id></a>
</dtml-if>
</dtml-if>
</dtml-if>
</dtml-in>
</dtml-unless>
<!-- End Breadcrumbs -->

(Yeah, I know I don't need all the complexity here but when I 
stripped it all out and got back to the simpler version, no change 
took place.)

This is defined at the root level of the Zope instance rather than in 
the danshafer folder since I may want to use it on other sites as 
well. Seems logical, no?

Now the navigation area looks like this:

Home > danshafer > danshafer > OMO > One Man's Opinion About the Arts

Notice the repeated danshafer again. And again, all of these links 
take the user back to the front door of the danshafer site.

So, Elkins at hurrah.com suggested I add a SiteRoot object to the 
danshafer folder, give it a base of http://www.danshafer.com and a 
root of "/". I did that. It got rid of the duplicated danshafer's in 
the URL just fine, but the other problems persist or get worse.

Now when I use the simple breadcrumb type of navigation link, it 
shows at the top of the page:

Home > danshafer > OMO > One Man's Opinion About the Arts

The first three are links and they all go to the same place: the top 
leve of the danshafer.com site. This happens even if I add an 
index.html DTML Document object to the OMO folder, which I find a tad 
bewildering. But since that's not the behavior I want anyway, that's 
a side issue; I just thought it might be a clue for someone.

So I try a Navigation object called DSNavigator defined in the 
danshafer folder. Following the example that comes with that product, 
I put the same code as above into the writingadvice.html page. The 
navigation bar now looks like this:

Dan Shafer Personal Site: Home of Infinite Possibilities : One Man's 
Opinion : One Man's Opinion About the Arts : Advice I Offer Aspiring 
Writers :

All are links. But all but the last one take me right back (you 
guessed it) to the front door of the site. Even though there is an 
index.html page in the omoarts folder, I never get a link to go back 
there.

So there you have it. One of the big reasons I was drawn to Zope was 
because I figured stuff like this would be pretty easy. It _appears_ 
to be but in practice I'm having a very difficult time making this 
work.

Any ideas, thoughts, hand-slaps, forehead-smiters...welcome and eagerly sought.

-- 
Hire a world-class ghostwriter to create your entire information product line!
Dan Shafer, author of 57 books (and counting) - Ghostwriting Unlimited, Inc.
dan@gui.com - 831-643-0590 (V) - 831-401-2531 (F)
http://www.gui.com