All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

search date range in matrix date field

makason 6 Nov 2012 23:53 problem, complete

Hi,

I'm working on a date range search within a matrix date field for a zoo_visitor channel. How can I access the matrix date field? I see the matrix member_histor field in the collection but not the matrix date field. {member_history}{sail_date}{/member_history}

If this date field is not indexed in the collection, is there a workaround?

Thanks

Replies

  1. Low 7 Nov 2012 00:08

    You can't target a Matrix cell specifically. The only thing you can do, is to make the date column searchable. If it wasn't searchable before, you'll need to re-save the entries, so it populates the exp_channel_data table with searchable content, which in turn is used by Low Search to build the index. Then you could search for a timestamp -- that's how the date field is saved...

  2. makason 7 Nov 2012 03:21

    Thanks for the quick reply.

    I have the matrix date column set to searchable. Now how do I pass a date range into the search form? The code below return all entries.

    {exp:low_search:form
    collection="zoo_visitor"
    secure="no"
    encode="no"
    result_page="kamaaina_admin/member_results"
    form_class="nice"

    }

    Search by Date



    Search

    {/exp:low_search:form}

  3. Low 7 Nov 2012 08:56

    Like I said, you can't target a single cell. If the Matrix field contains multiple rows of dates, it won't work. It will only work if there is just one row, and the date row is the only row that is searchable in the Matrix field. Then, you should be able to use the Ranges option to filter by numerical range.

    Since the field being searched is not a date field (but a Matrix field), you'll need to use Unix timestamps as values, instead of a YYYY-MM-DD syntax.

    Not guaranteeing this will work, tho. You'll be better off using a dedicated Date field in the channel for selecting the date range.

  4. makason 7 Nov 2012 18:45

    Thanks Low.

    For this particular search a custom sql query will be easier. I did a quick test and this is returning the entry_id 's I'm looking for . Great module though. Appreciate your quick response. You can close this thread.

    SELECT * FROM exp_matrix_data
    WHERE col_id_12
    BETWEEN UNIX_TIMESTAMP('2012-10-01') AND UNIX_TIMESTAMP('2012-11-01')