Countdown based on calendar does not reset properly. #391
-
What happened?I'm using craft calendar with custom api and jquery countdown. Just to keep this space clean all of the code can be found here: https://gist.github.com/JayGreentree/f0fa719ff45f768373754c066fa74563 Errors and Stack Trace (if available)How can we reproduce this?
Calendar EditionPro Calendar Version5.0.16 Craft Version5.6.14 When did this issue start?
Previous Calendar VersionNo response |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments
-
Hi @JayGreentree, I sort of cheated and ran this one through ChatGPT. It suggests the following:
Can you see if this helps at all or at least gets you closer? 🙂 |
Beta Was this translation helpful? Give feedback.
-
With help over on craft discord I did manage to fix the js side. However the calendar now seems to be the issue. testing my json data it isnt changing after the event ends https://jaygreentree.org/api/data.json is the working json |
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay @JayGreentree. I just want to check in... are you still experiencing issues with this? And if so, can you provide us with more information? 🙂 |
Beta Was this translation helpful? Give feedback.
-
The javascript side is working but what I was trying to do is figure out how to load the next scheduled event after the previous one has ended. Currently it does not load the next even until 12am the following day. For example each week I have Wednesdays from 6:00 pm - 8:00 pm and Fridays from 6:00 pm - 8:00 pm. At 8:00pm on Wednesday or shortly after it needs to load the Friday 6:00 pm - 8:00 pm. However it does not pick up Friday until 12am on Thursday. |
Beta Was this translation helpful? Give feedback.
-
I dont know if this helps or not: |
Beta Was this translation helpful? Give feedback.
-
@kjmartens I did some more digging and it appears to be related to repeating events. if I set the event to not repeat it shows the countdown for the next event as expected. |
Beta Was this translation helpful? Give feedback.
-
@JayGreentree Can I see {% include 'isLive.twig' %} ? |
Beta Was this translation helpful? Give feedback.
-
@JayGreentree I have setup the following event Its now 16:19 so the event is live ATM. When I view the countdown template, I get 23:59:59. In my data.json, I just set Is this what you get? Are you expecting to get 2 days, 1 hour, 38 minutes and X seconds ? |
Beta Was this translation helpful? Give feedback.
-
{% if craft.youtubelive.isLive() %}
true
{% else %}
false
{% endif %}
Yes I get 23:59:59. and then it resets back to that on page refresh until midnight. Once it hits midnight it then gets the next event. I did get some help with the js side so when the countdown hits zero I either get the "live now" link or "event has ended"
Yes after the current event has ended. |
Beta Was this translation helpful? Give feedback.
-
Hi @JayGreentree, Does your project have any sort of budget for premium support? What I can do is have our developer work through your code and correct the issue(s) for you. Let me know if that interests you or if you have any questions. 🙂 |
Beta Was this translation helpful? Give feedback.
-
Unfortunately no since it is currently for my personal website. I was hoping to eventually use this for a church once I had it working properly. |
Beta Was this translation helpful? Give feedback.
-
@JayGreentree Calendar handles repeating events correctly. So the issue is within your Twig and JS. By default, when you query
Then in your JS, check for next upcoming event and compare the current time with each of the event times, and select the next upcoming event start date time in your countdown timer. |
Beta Was this translation helpful? Give feedback.
@JayGreentree
Calendar handles repeating events correctly. So the issue is within your Twig and JS.
By default, when you query
craft.calendar.events
, it returns base events, not individual occurrences of repeating events. You want the next upcoming occurrence, not the base event. Looking at your Gist, you are usingevent.startDate
and this is giving you the first occurrence's date, not the next upcoming event date.