0

We have a large festival events site where each performance is stored in a matrix field called dates which uses a single block which has a datetime field (date only). So if an event is on 3 different days, there will be 3 blocks in this dates matrix field, each with the date field set.

The site has events filtering/search functionality where you can filter events by a number of criteria, including particular dates. This is implemented using an entries query setting various category, field conditions and the search parameter.

In Craft 2, we used the search parameter to search the matrix field for date values. We recently upgraded the site to Craft 3 and this approach still worked for existing unedited entries.

craft.entries.section('events').search('dates:2020-01-01')

However, we have now realised that this no longer works for any new entries added in Craft 3. Searching for a date just returns no results from these new entries.

Also, if we go back and edit the dates matrix field for an old entry and save it, the date search no longer works for that entry either. Even if we restore it to an old revision afterwards, it still doesn't work.

So it's as if saving entries in Craft 3 treats the datetime field within the matrix field differently than before and it is no longer searchable via the .search('matrixfieldname:value') approach?

Does anyone know of a way to search a date field within a matrix field in Craft 3? We just need to search the entire matrix field content for particular date values/strings. We don't need to be able to search only the datetime field within the matrix.

The site is currently running Craft 3.4.9 and has 2 locales in case that is relevant, but the events section is only in the primary site.

Thanks for your time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.