I help manage a few sites where we schedule content to turn on and off when a team member is unable to push it live or take it down manually. This is the code solution that my colleague developed to make this happen with certain strips. Recently it hasn't been working as intended, and I would like to collapse a strip as well on the same date or time.
$w.onReady(function () { var startD = new Date('07/14/2021'); var endD = new Date('08/05/2021'); var today = new Date(); if(startD >= today || endD <= today) { $w('#columnStrip2').hide(); $w('#columnStrip5').show(); } else { $w('#columnStrip2').show(); $w('#columnStrip5').hide(); } });
Has anyone developed an easier or more reliable solution for this? (My coding skills are rudimentary, but this doesn't seem like too much to ask for a business website.)
To achieve your aim, i think much more coding will be needed.
How to create your Shedule-Manager-Function ?
1) At first step i would generate a DATABSE where i would store the different STATEs for every Shedule-Function (even if needed for every single user).
2) Generate your Shedule-Manager-Page-Design, adding some elements like..
Inputfields + Datepicker and so on.
On this site you will be able to generate "Shedule-Tasks". All the generated "shedule-tasks" will be stored inside a database for each ELEMENT on your site (if needed even for every individual USER or what ever needed).
3) On your (i will call it) --> "OUTPUT-SITE" you will have your --> onReady-Code running which will load immediately all needed DATA out of the DB, for every SINGLE ELEMENT, every SINGLE USER, EVERY SINGLE SITUATION, which was saved before in DB.
But perhaps i also thinking to complex, or even the wrong way and you have had something other on your mind.
Simple working example (using Date-Picker)....
$w.onReady(function () { const today = new Date(); console.log(today) $w('#datePicker1').onChange(()=>{ let startD = $w('#datePicker1').value; console.log("START-DATE: ", startD) //let endD = $w('#datePicker2').value; console.log("END-DATE: ", endD) if(startD>=today) { $w('#columnStrip1').hide(); $w('#columnStrip2').show(); } else { $w('#columnStrip1').show(); $w('#columnStrip2').hide(); } }); });
Choose a higher date than --> TODAY in the left DATE_PICKER <-- and take a look what happens. Try it again with a lower DATE.