[Zope] Question: Passing variables several levels
John Goerzen
jgoerzen@complete.org
03 Sep 1999 23:55:11 -0500
OK, Here's the story. I have several cases in which I'd like to have
a horizontal bar. So, I defined a DTML method at the top of the
hierarchy named Banner_Bar_Generic. This works in isolation. Then, I
have a DTML method named linkHome that generates a relative link
containing a sufficient number of "../" entries to take the user back
to the top of the site. This also works in isolation, but oddly
enough, only when called as <dtml-var linkHome>, and not as <dtml-var
"linkHome">; the latter apparently has problems passing PARENTS or
REQUEST. linkHier (not shown; also works in isolation and has an
implementation similar to linkHome) generates a strong showing where
the person is in the site; ie "Air Capital Linux Users Group:
Information: Free Software", in a Yahoo fashion.
Now, the question. I want to put a top bar on each page, containing
these sorts of links. So, I figure I ought to define a
Banner_Bar_Top, implemented in terms of Banner_Bar_Generic. However,
I can't figure out how to pass along the proper strings; I always get
a Zope error. Here's my latest attempt at this. Also below is the
code for the other DTML methods. Any suggestions are welcome!
*** Banner_Bar_Top:
<dtml-with REQUEST>
<dtml-with PARENTS>
<dtml-with "_.namespace(StopAt='ACLUG')">
<dtml-var "Banner_Bar_Generic(
ltext='<FONT FACE=' + 'helv,helvetica,arial' + '>'+
linkHier + '</FONT>',
rtext='<A HREF=' + linkHome + '><FONT COLOR=#FFFFFF>Home</FONT></A>',
bgcolor='#9C0000')">
</dtml-with>
</dtml-with>
</dtml-with>
*** Banner_Bar_Generic:
<dtml-comment>
Arguments are:
ltext -- text for left side
rtext -- text for right side
bgcolor -- background color
</dtml-comment>
<TABLE
BORDER="0"
WIDTH="100%"
ALIGN=center
CELLSPACING="0"
BGCOLOR="<dtml-var bgcolor>">
<TR>
<dtml-comment>If no right text, align to center.</dtml-comment>
<dtml-if rtext>
<TD ALIGN=left>
<dtml-else>
<TD ALIGN=center>
</dtml-if>
<FONT COLOR="#FFFFFF"><dtml-var ltext></FONT>
<dtml-if rtext>
<TD ALIGN=right>
<FONT COLOR="#FFFFFF"><dtml-var rtext></FONT>
<dtml-else>
<!-- No right text defined -->
</dtml-if>
</TABLE>
*** linkHome:
<dtml-comment><dtml-in "PARENTS">
Item: '<dtml-var "PARENTS[_['sequence-index']].id">'<BR>
</dtml-in>
</dtml-comment>
<dtml-call "REQUEST.set('InsertStr', '../')">
<dtml-in "PARENTS"><dtml-if "PARENTS[_['sequence-index']].id != StopAt"><dtml-var InsertStr><dtml-else><dtml-call "REQUEST.set('InsertStr', '')"></dtml-if></dtml-in>
Thanks,
John Goerzen
--
John Goerzen Linux, Unix consulting & programming jgoerzen@complete.org |
Developer, Debian GNU/Linux (Free powerful OS upgrade) www.debian.org |
----------------------------------------------------------------------------+
The 60,733,058th prime number is 1,205,825,459.