Page 1 of 1
CGCalendar upcominglist skipping events
Posted: Tue Apr 05, 2022 3:56 pm
by mecca
Hi guys,
out of the blue we have the problem that some events in the upcoming list are being skipped. This is our content:
{cms_module module='CGCalendar' display='upcominglist' limit='5'}
We have some events in April, May and June that are skipped.
Weirdly, when I set the limit to 20 for instance, the actual upcoming events are not skipped. I guess it has something to do with how the system sorts or queries the events but I dont even know how to debug that or where to look. Any ideas?
Re: CGCalendar upcominglist skipping events
Posted: Tue Apr 05, 2022 5:57 pm
by DIGI3
Do 5 events show, or does it show less than 5 when it skips some? If the latter, then there's probably some template logic preventing them from showing.
If it's showing 5 other events then my guess would be a date formatting issue - but that would depend where they show up when you display 20 events. I don't think there's a known bug that would cause this behaviour so it's likely something unique to those events, your setup, or your templates.
Re: CGCalendar upcominglist skipping events
Posted: Thu Apr 07, 2022 1:27 pm
by mecca
Hey DIGI3,
thanks for your feedback so far. It is showing 5 events but skipping the closest ones. Events for April, May and June are completely skipped and starting with the July 1st the output starts.
As far as I've seen there is no date skipping or comparison logic in my template. In my understanding, that must be a db query and the n results are being rendered with a template. Any idea where the actual logic happens? I also guess it has to do with date formatting but I believe thats all untouched by me.
I also have a "normal" list with all events ordered in ASC date and that works fine, dates for April, May, June, July, etc are shown in the correct order. The content is:
{cms_module module='CGCalendar' display='upcominglist'}
Could it be that the limit is called before the ordering under the hood? Something like get the last created events and sort by upcoming or something?
Re: CGCalendar upcominglist skipping events
Posted: Thu Apr 07, 2022 2:28 pm
by DIGI3
It's entirely possible there's a bug but it would be strange to only be hearing about it now. I don't know the underlying logic, and the author has abandoned the module so it's going to be a tough one. Perhaps one of the module devs who use this will consider forking it and can look deeper into your issue.
If you can recreate it on another installation that would be helpful, I still do think it's specific to yours but it's hard to tell without doing my own tests and troubleshooting on it.
Re: CGCalendar upcominglist skipping events
Posted: Thu Apr 07, 2022 3:21 pm
by velden
What version of CGCalendar are you using?
You could also try to enable
debug mode and see if the relevant queries are displayed on your page.
You can then first inspect the queries and secondly run them on your database to see what the results are.
The most relevant query has this string in it so you could search that on your page: 'module_cgcalendar_events WHERE event_id IN'
Re: CGCalendar upcominglist skipping events
Posted: Fri Apr 08, 2022 12:46 am
by paulbaker
Just to add I use CGCalendar in the same way as you and I have never seen the behaviour you describe. So I don't think it's a module bug. Not sure what it is though...
Here are 2 module calls.
Code: Select all
{cms_module module="CGCalendar" display="upcominglist" limit="3" listtemplate="UpcomingHome2" displayforday="true"}
Code: Select all
{cms_module module="CGCalendar" display="upcominglist" displayforday="1" limit="4" listtemplate="CGCalendar-List-View-UpComingSide"}
Re: CGCalendar upcominglist skipping events
Posted: Mon Apr 11, 2022 11:00 am
by mecca
Hey everyone,
thank you so much for taking your time and helping me. Debugging the query was very helpful. The following query was built:
Code: Select all
SELECT DISTINCT E.event_id FROM cms_module_cgcalendar_events E
WHERE ((E.event_date_start >= '2022-04-11 00:00:01') OR (E.event_date_end > '2022-04-11 00:00:01')) AND E.event_status = 'P' LIMIT 5
Which, to me, seems like a big bug in CGCalendar since events that have been created first but actually take place later in the year are being shown first (I get asc event ids). I think it should be something like this:
Code: Select all
SELECT DISTINCT E.event_id FROM cms_module_cgcalendar_events E WHERE ((E.event_date_start >= '2022-04-11 00:00:01') OR (E.event_date_end > '2022-04-11 00:00:01')) AND E.event_status = 'P' ORDER BY E.event_date_start ASC;
I am using version 2.6.2 and CMS does not find any update. How do I proceed from here? Do I have a faulty version or any idea where I can alter the query in the code?
Thanks again.
Re: CGCalendar upcominglist skipping events
Posted: Mon Apr 11, 2022 4:17 pm
by velden
I think that code comes from
lib\class.cgcalendar_utils.php starting at line 307
However, line 352 holds the ORDER BY statement, so I'm surprised it doesn't show up in your logging.
The module is abandoned by its developer. So for now you can either fork the module and become the dev yourself

or alter the code in your install.
But first I'd try to find out why your query doesn't hold the order by statement.
Re: CGCalendar upcominglist skipping events
Posted: Tue Apr 12, 2022 9:03 am
by mecca
@velden Can you imagine - line 352 was commented out in the code! Thank you so much for your support everyone, it works now.
Re: CGCalendar upcominglist skipping events
Posted: Tue Apr 12, 2022 11:08 am
by paulbaker
paulbaker wrote: ↑Fri Apr 08, 2022 12:46 am
Just to add I use CGCalendar in the same way as you
Confession time....the sites I quoted do not use the latest version of CGCalendar, which is why I was getting different behaviour. Glad you sorted it.
Sounds like this should be added as a bug?:
http://dev.cmsmadesimple.org/bug/list/623
[SOLVED] Re: CGCalendar upcominglist skipping events
Posted: Wed Apr 13, 2022 8:05 am
by mecca
Well when I download the module line 352 is not commented out, so it mustve been someone in the past that fiddled with the modules code on our site. Doesnt seem like a bug but an individual problem.