Searching Low Events by separate month and year fields
I have low events and low search installed.
How do i search my events with the following fields?
- Month (01-12)
- Year (This year to 5 years time)
Your example is searching by date, but i need separate month and year fields.
How do i do this?
Replies
Low 6 Jun 2014 13:00
Right now, the parameters needed to filter by date are identical to the parameters available in the Low Events entries tag. There are no separate params for month and year, so you'd need to work around that if you do want to use 2 separate fields.
For example, you could create a hidden input field with name="low_events:date" and set the value of that field with JavaScript, based on the month and year fields, when the form is submitted.
billyp 6 Jun 2014 13:04
Right, i thought that might be the case. Just wanted to check.
Cheers!
billyp 6 Jun 2014 14:38
I have it nearly working, the last part is to populate the month and year drop down using the low_events:date value after the user has submitted the form.
How do i get this value?
I have tried {low_search_date} but it is coming back empty.
Low 6 Jun 2014 14:41
The value will be {low_search_low_events:date}. But if you name the two dropdowns, you can use those values as well, for example:
...will generate a {low_search_event_year} variable you can use. The parameter "event_year" will have no other effect.
billyp 6 Jun 2014 14:46
Aaaahh!! I never thought to use the two dropdown names. Saves me having to split the date into two strings etc,etc.
Perfect!!
Low 6 Jun 2014 14:48
Just be careful not to name them "year" or "month", as those two are actual native parameters and therefore will filter entries based on entry dates.
billyp 6 Jun 2014 14:49
I generally never name any vars in that way.
Eliminates name conflicts as a reason for when debugging.