[Zope] DTML for "where am I"?

Jean Jordaan jean@upfrontsystems.co.za
Tue, 4 Dec 2001 17:50:00 +0200


Hi all

I have the following snippet of DTML to link to a reminder::

 <dtml-if "URL1[_.len(BASE0):] == '/Reminders'">
 <a href="./Reminder/view?r=<dtml-var id>">
 <dtml-else>
 <a href="./Reminders/Reminder/view?r=<dtml-var id>">
 </dtml-if>

Its purpose is as follows:

 - If I am in the Reminders specialist, the path to the 
   Reminder instance should be:

   http://server:11080/Reminders/Reminder/view?r=reminder13

 - If I am elsewhere, the path should be, for example:

   http://server:11080/Products/1/Reminders/Reminder/view?r=reminder13

   so that 'Reminders' can be acquired, and 'Reminder/view' be
   found from there.

Without the check, the path would be 
   http://server:11080/Reminders/Reminders/Reminder/view?r=reminder13
in the first instance, which looks ugly, and messes up my breadcrumbs
trail.

What I'm looking for is beautiful DTML for saying "if my context is
the Reminders specialist, then do something special". The current
 <dtml-if "URL1[_.len(BASE0):] == '/Reminders'">
gets the job done, but I wouldn't call it pretty. Anything elegant
I'm missing?

Regards,
Jean Jordaan