Im creating a page for a bar that has weekly events on repeat.
Sunday Funday
Monday Karaoke
Tuesday Trivia
etc
I want to be able to display do the home page “Happening tonight” based on which day of the week it is but I can’t seem to find a way to do that other than assigning actual dates to the event, and I want to basically just set this and forget this.
Any recommendations or guidance would be greatly appreciated.
Follow the instructions and add the attributes.
Your filter function would look something like this;
<script>
function isTodaysWeekday(item) {
var today = new Date();
var weekday = $(item).find("data").attr("weekday");
// Check to see if weekday number = today
// https://www.w3schools.com/jsref/jsref_getday.asp
if (today.getDay() == weekday)
return true;
return false;
}
</script>
In your CMS collection, you’d have a Weekday column, numeric, and specify the weekday for each item as;
0 = sunday, 1 = monday, etc…
I have a question similar to this one, but in my case the same event happens on 3 different days of the week (say, Mon, Wed, Fri). Is there a way to assign more than one day of the week to the same event?
Thank you!
Use the Sygnal Attributes filter lib above, put those custom attributes on the collection item as well, and write the filter function accordingly to filter based on those attributes.