Events search with simple month drop down search option


(Charlotte Westney) #1

Matrix Version: 5.3.4.0

Hi everyone,

I’ve got an events page with various views - next 7 days, next 28 days, all bookable events (a stored events search).
http://www.lakedistrict.gov.uk/visiting/events

The team now want to change the events search, so that it still has the dropdown for event category (metadata), and then a date search as a simple drop down of months, ideally starting at the current month and then select options for each subsequent month in the current year.

I have no idea how to achieve this seemingly simple request.

I’m thinking it needs to stay as an events search - so that I can keep the category filter, but is there a way, other than hardcoding in a select field, to search for all events where the start date matches just a set month?

All ideas welcome!
Charlie.


(Bart Banda) #2

The easiest thing I can think of is to create a metadata field with a default and non-editable value of %event_start_datetime_F% which would then print the month the event happens in. Then your search can just target that field for the month filtering?


(Charlotte Westney) #3

Hi Bart,

I had that exact same thought, and set up a metadata field exactly like that!

Now just need some nifty javascript that can generate that form select field so it starts at whatever the current month is…

Thanks Bart!
C

EDIT — No, I don’t need JS, I just need some Matrix conditional keywords of course!

Check what the current date is, and only show the option for a set month if its less than the 1st of the next month. And then use a globals keyword for the year so it will work next year without recoding. Feeling pretty smug :wink:

%begin_globals_date^replace_keywords:^lt_date:{%globals_date_Y}-02-01%January%end_globals_date% %begin_globals_date^replace_keywords:^lt_date:{%globals_date_Y}-03-01%February%end_globals_date%