[Zope] dtml-with and only

Loren Stafford lstafford@icompression.com
Wed, 3 Nov 1999 09:34:30 -0800


Sorry, I wasn't very explicit in that last message.

I used hasProperty(id) in a similar situation, like this:

  <!--#with "PARENTS[-1]"-->
  <!--#if "hasProperty('button_on') and hasProperty('button_off')"-->
 <td class="navd" align="right">
  <a href="<!--#var absolute_url-->"
  onMouseOver="if (document.images) document.bhome.src='/images/<!--#var
button_on-->'; return true;"
  onMouseOut="if (document.images) document.bhome.src='/images/<!--#var
button_off-->';
  return true;"><img name="bhome"
  src="/images/<!--#var button_off-->" border="0" vspace="0" WIDTH="117"
  HEIGHT="39" ALT="<!--#var title_or_id-->"></a>
 </td>
  <!--#else-->
 <td class="navc" align="right">
  <A HREF="<!--#var absolute_url-->">&lt;&lt;home</A>
 </td>
  <!--#/if-->
  <!--#/with-->

HTH
-- Loren

> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Barry
> A. Warsaw
> Sent: Wednesday, November 03, 1999 09:01
> To: zope@zope.org
> Subject: [Zope] dtml-with and only
>
>
>
> I'm sure this is a newbie question, so go easy on me :)
>
> Anyway, I've finally gotten around to mocking up the python.org
> website in Zope.  I saw some neat code called Breadcrumbs which
> includes a list of parent links to the page you're sitting on, e.g.
>
> Home > Community > On-line PSA Registration
>
> Naturally, I modified the DTML to do things a little differently, and
> one of the things I want to do is to be able to add title
> abbreviations (i.e. nicknames) to some folders, using them in
> preference to title or id (I want a sort of nickname_or_title_or_id
> method).  So the idea is to add a property to some folders called
> `nickname' and use that if it exists, otherwise use the title_or_id.
>
> The problem of course is that I do not want `nickname' to be
> acquired.  I figured I could write DMTL like the following to
> accomplish this:
>
> -------------------- snip snip --------------------
> <dtml-with folderobj only>
>    <dtml-if nickname><dtml-var nickname>
>    <dtml-else><dtml-var title_or_id>
>    </dtml-else>
> </dtml-with>
> -------------------- snip snip --------------------
>
> From the docs, it seems that the `only' tag should stop the name
> search in enclosing namespaces, but this doesn't seem to work.  In my
> root folder, I include a nickname property, and set it to "Home".  In
> a subfolder (say "psa") I do not have a nickname property, but this
> DTML method is returning "Home" for both folder objects.
>
> I've also tried substituting the dtml-if test with something like
>
>     <dtml-if "_.hasattr(folderobj, 'nickname')">
>
> but that didn't seem to make a difference.
>
> Is this enough information to help?  I'm sure I'm either
> misunderstanding some simple concept or doing some dumb newbie lose.
> Any help will be appreciated.
>
> Thanks,
> -Barry
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
>           No cross posts or HTML encoding!
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>