I'm trying to create a dtml-calendar which searches a Z catalog using a custom field on one of my Z classes. I've tested the search by hand, and it seems to work. I seem to be having a few issues with DTML, though. Here is my code: <dtml-var standard_html_header> <dtml-calendar> <dtml-call "setCalendar('valign','top')"> <dtml-let d="date.Date()" hasdate="hasProperty(d)" dprop="getProperty(d)" e="getCatalog().searchResults(meta_type='Event', event_date=date)"> <dtml-if "e"> <dtml-let path="SiteIndex.getpath(e[0].data_record_id_)"> <a href="&dtml-portal_url;&dtml-path;"><dtml-var "date.dd()"></a> </dtml-let> <dtml-else> <dtml-var "date.dd()"> </dtml-if> <br> <dtml-if "hasdate==1"> <dtml-var dprop> </dtml-if> </dtml-let> </dtml-calendar> <dtml-var standard_html_footer> The problem line is <dtml-if "e">. What I was intending to do is perform the code if the search result actually returned something, but this doesn't seem to be happening. What I'd like to do is: <dtml-if "len(e) > 0)"> But, len() doesn't seem to be defined in whichever namespace the code is being run in. I tried: <dtml-call "global len"> before the dtml-if, but this errored out as well. Am I completely misunderstanding the problem which I'm having? Thanks.
On Mon, 6 Mar 2000, Nolan Darilek wrote: [snip]
The problem line is <dtml-if "e">. What I was intending to do is perform the code if the search result actually returned something, but this doesn't seem to be happening. What I'd like to do is:
<dtml-if "len(e) > 0)">
But, len() doesn't seem to be defined in whichever namespace the code is being run in. I tried:
<dtml-call "global len">
before the dtml-if, but this errored out as well. Am I completely misunderstanding the problem which I'm having?
To use len, try: <dtml-if expr="_.len(e) > 0"> It is part of the _ namespace. You may also be able to achieve the same result (depending on the types of data involved) using: <dtml-if e> Note the lack of quotes.
Thanks.
You're welcome. --Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
participants (2)
-
Jeff Hoffman -
Nolan Darilek