[Zope] - Problem with multiple inputs
skip@calendar.com (Skip Montanaro)
skip@calendar.com (Skip Montanaro)
Tue, 26 Jan 1999 07:30:22 -0500
One of my search forms allows people to search using one or more keywords.
If they select one keyword it's delivered as a string. If they select
multiple keywords it's delivered as a list. In the search results page I
want to generate a new search form that contains the input parameters from
the search to make it easy to generate a related search. I currently have
<!--#if keywords-->
<!--#in keywords-->
<input type=hidden name="keywords" value="<!--#var sequence-item-->">
<!--#/in-->
<!--#/if-->
This fails if the user selected just a single keyword, since the keywords
parameter is a string. Is there some clean way to work around this problem?
The only thing I can see is something like
<!--#if keywords-->
<!--#if "type(REQUEST['keywords']) == type('')"-->
<input type=hidden name="keywords" value="<!--#var keywords-->">
<!--#else-->
<!--#in keywords-->
<input type=hidden name="keywords" value="<!--#var sequence-item-->">
<!--#/in-->
<!--#/if-->
<!--#/if-->
which fails because the builtin function type is apparently not available.
I also tried using "_.type(...)" but that failed with an AttributeError (was
that the correct syntax?). My short-term solution is to add a hidden
parameter with a dummy value that guarantees if the user selects a keyword
there will be at least two keywords, thus I'll get a list I can loop over
with #in. Is there a cleaner way out of this mess?
Thanks,
Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/
skip@mojam.com | Musi-Cal: http://www.musi-cal.com/
518-372-5583