Ok, it appears that len() isn't what I want. I was under the impression that searchResults() returned an object which functioned as a list, but this wasn't right, apparently. Or maybe it was, *shrug*. :) Here's my current code, which I've modified a bit for testing purposes: <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="getCatalog().getpath(e[0].data_record_id_)"> <a href="&dtml-portal_url;&dtml-path;"><dtml-var "date.dd()"></a> </dtml-let> <dtml-else> <a href="&dtml-portal_url;/&dtml-date;"><dtml-var "date.dd()"></a> </dtml-if> <br> <dtml-if "hasdate==1"> <dtml-var dprop> </dtml-if> </dtml-let> </dtml-calendar> <dtml-var standard_html_footer> This code generates links as it should. What I'm trying to do though is, if an object of the Event class exists with an event_date which equals the current rendered date, I'd like to link directly to it. I can successfully search for the date using the PTK's search form, so I'm fairly sure that my issues with the catalog are resolved. So, what exactly is being returned by searchResults, and how can I determine whether my search yielded anything, so that I can display a link to the item?
Nolan Darilek wrote:
Ok, it appears that len() isn't what I want. I was under the impression that searchResults() returned an object which functioned as a list,
searchResults returns a Python sequence (that happens to be a list).
but this wasn't right, apparently. Or maybe it was, *shrug*. :) Here's my current code, which I've modified a bit for testing purposes:
<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="getCatalog().getpath(e[0].data_record_id_)"> <a href="&dtml-portal_url;&dtml-path;"><dtml-var "date.dd()"></a> </dtml-let> <dtml-else> <a href="&dtml-portal_url;/&dtml-date;"><dtml-var "date.dd()"></a> </dtml-if> <br> <dtml-if "hasdate==1"> <dtml-var dprop> </dtml-if> </dtml-let> </dtml-calendar> <dtml-var standard_html_footer>
This code generates links as it should. What I'm trying to do though is, if an object of the Event class exists with an event_date which equals the current rendered date, I'd like to link directly to it. I can successfully search for the date using the PTK's search form, so I'm fairly sure that my issues with the catalog are resolved.
So, what exactly is being returned by searchResults,
a sequence of record objects that describe cataloged objects that match your search query. The are NOT the actual objects themselves, just 'descriptions' that can be used to refer to the objects (with 'getpath' as you discovered, or 'getobject').
and how can I determine whether my search yielded anything
In your case, <dtml-if e> There are results. <dtml-else> There are not results. </dtml-in>
, so that I can display a link to the item?
I don't undertand what you mean, you code apears to do this. BTW, it is much easier for other people (or at least me) to assist you if they can read your code. For python programmers, this means indenting it sensibly. -Michel
participants (2)
-
Michel Pelletier -
Nolan Darilek