1

I'm trying to set up a search form that searches several things:

  1. name
  2. date
  3. location

The site in question is a funeral home, and we want to set up a search where people can search by the name of the deceased, the location of the funeral, or the date of death. The name and location search work great, but I get no results when I search by date.

I've set it up so that the date that gets sent to the Low Search module is formatted as YYYY-MM-DD, but that doesn't seem to matter.

Your talk about range would apply here, but I only want to search for a single date, not a range of dates. In any case, I did try range-from (as you see below) and a hidden input for range-to with the same value. That didn't work.

Previously, I didn't use a range at all, and Low Search would return every all results (over 8500 of them!).

My Code

{exp:low_search:form collection="obits|obits_archive" form_class="obit-search" query="" result_page="obit/results" secure="no"}
  <ul>
    <li><label>Name<br/>
    <input type="text" name="keywords" /></label></li>
    <li><label for="date-pick">Date of Death<br/>
    <input type="text" name="range-from:ob_dod" id="date-pick" value="" /></label><input type="text" style="display:none" name="range-to:ob_dod" /></li>
    <li><label>CCG Location<br/>
    <select name="child:ob_location[]">
      <option value="">All Locations</option>
      {exp:channel:entries channel="locations" dynamic="no" orderby="title" sort="asc"}
      <option value="{entry_id}">{title}</option>
      {/exp:channel:entries}
      </select></label></li>
    <li><input type="submit" name="submit" value="Search" id="submit" class="button"></li>
  </dl>
{/exp:low_search:form}

Other Info

You'll almost certainly want to know that the date is not using EE's date fieldtype, but, rather, Stephen Lewis's Dropdate. Dates are stored as a UNIX timestamp.

2 Answers 2

0

As BKY mentioned, I'd go for an exact match here, instead of a range. You say you're saving the DropDate field as a UNIX timestamp. Low Search's range option only transforms a given date range to timestamps if the field is a native date field. Third party date fields aren't supported that way.

Given that, I'd set DropDate to save the date as YYYYMMDD, so an exact match is easier to get. As a parameter, you could use search:ob_dod="20130201" (Feb 1st, 2013) for an exact match of the DropDate field. Used as an input field in the Form tag, you can then use something like this:

<input name="search:ob_dod" />

...and perhaps use a datepicker or some custom JS to get the needed YYYYMMDD format.

2
  • There appears to be a bug in DropDate that the entered date of death gets reset on saving (even though it's a required field). I'll apparently need to convert to a UNIX timestamp prior to sending the data to Low Search. Either that, or I fix the bug.
    – cherrypj
    Feb 5, 2013 at 13:28
  • We ended up not needing this solution (client decided they no longer wanted a date search), but marking your answer as the because you expanded on @bky post.
    – cherrypj
    Feb 5, 2013 at 22:03
0

How are you saving the date with DropDate field i.e in "UNIX timestamp" or "YYYYMMDD"? In this way you can directly match the "Date of Death".

Also, you will need to have some JavaScript stuff to convert the date format in either "UNIX timestamp" or "YYYYMMDD" OnChange the "Date of Death" input value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.