I’m building a site for a radio station and I want to create a schedule for the current day.
My solution is to get the data from the collection “Programs” where I have inserted an option field with numbers 0 - 6 for each day of the week. I have then put embedded code component inside the cms item and pulling the data dynamically from the option field in the programs collection by adding field from cms.
This is my code
<style>
.noresults {display: none;}
</style>
`<script>`
const date = new Date();
const today = date.getDay();
if (Day != today) {
$(this).addClass("noresults");
} else {
$(this).removeClass("noresults");
};
`</script>`
Can you share a link to the published version so we can see the code running? Also you can create filter for the current date natively in Webflow if you use a date/time field in your collection.
Yes I have tried the date/time method in webflow but I don’t think it will work on recurring events without changing the date manually. If it’s possible please share how because I’d rather do it natively in webflow.
Your published site code doesn’t reflect what you posted here. You have a script section with the first 2 lines and then end script and then another section with more code later which throws a Syntax Error so you need to fix that.
To set a today filter you can do something like this screenshot:
Thanks for the reply.
I’ve solved the syntax errors but it still won’t work.
I’ve tried the method you’ve suggested but the problem is that the cms item won’t know what “today” is unless it’s a specific date and that won’t work with recurring events.