CGCalendar events conditional link

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

CGCalendar events conditional link

Post by jakovbak »

Hello everyone!
I'm trying to modify CGCalendar just a little bit but I need some help with coding.
Among others, I have two categories: "closed" and "in_progress". If an event belongs to one of those categories, users must not be able to click on the event to see details. I need to "kill" that link. And my efforts were embarrassing...
Basically, it could be something like this:

Code: Select all

eventClick: function(event, jsEvent, view) {
     if(  category != 'closed' or category != 'in_progress' ) {
          window.location = event.none;
     }
     else {
          window.location = event.detail_url;
     }
}
I know it's far from proper code but perhaps it could illustrate what I am trying to achieve.
Thank you in advance for any kind of help!
Best regards,
Jakovbak
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar events conditional link

Post by velden »

Just saying: CGCal uses fullcalendar.io for displaying the calendar(s): https://fullcalendar.io/

It might help you in your search to a solution. I'm pretty sure it can be done but it requires good understanding of JS.
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: CGCalendar events conditional link

Post by jakovbak »

Hello Velden!
Great link and it looks like my problem could be solved in a couple of ways. Unfortunately, so far I have only concluded (maybe I'm wrong?) there is no implementation of certain capabilities in CGCalendar module.
For instance: 'background events' don't allow eventClick and it's exactly what I was looking for but there is no parameter in CGCalendar to describe an event as 'background event'. "Category" is the only available parameter for describing an event.
However, I have yet to explore what can be done by using GoogleCalendar but I'm not very optimistic about it. From what I have seen in fullcalendar.io Docs, administrator won't be able to take care of the calendar this way, it would be far too complicated for that person.
So, I'll dig a little deeper into this stuff and maybe I figure something out after all but I'll also ask around on some other forums.
Have a great day and best regards!
Jakovbak
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar events conditional link

Post by velden »

Indeed it seams that CGCalendar only provides a fixed set of properties to the front-end calendar (fullcalendar).

Perhaps you can (mis)use categories for your purpose.
I can think of other solutions but it would mean some customizations using UDTs etc. Probably not best practice.
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: CGCalendar events conditional link

Post by jakovbak »

That's what I had in mind - the misuse approach - but still haven't find the way to do it. But, except the tweaking the code from the top of this topic (I thought it would be the easiest way to do it), nothing else crossed my mind.
Still waiting for suggestions from js forums...
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: CGCalendar events conditional link

Post by jakovbak »

Meanwhile, I came across this:

viewtopic.php?f=7&t=75479&hilit=CGCalendar

I have seen eventRender callback in fullcalendar.io documentation but I have no idea how to use it within CGCalendar module. This callback is used for - imagine this - giving an event a "background" status! And events with such status don't create link for detail view in the front end!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar events conditional link

Post by velden »

Do you have an url to a page using this calendar?

Watching the calendar code it seems to me as if the category is not provided to fullcalendar.

However, a 'color' and 'textColor' property are for that category.

Untested example for a category with color #ffffff

Code: Select all

eventClick: function(event, jsEvent, view) {
     if(  event.color != '#ffffff') {
          window.location = event.detail_url;
     }
}
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: CGCalendar events conditional link

Post by jakovbak »

It's still in progress on my computer but similar calendar is here:

http://www.bakinidvori.studioides.com/i ... ailability

Go to August, there is one period marked as "occupied" and in my calendar it would be marked as "closed".
Front and back colors - chosen in event editor via category - are inserted in link style. But the category itself left no trace in front end code...
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: CGCalendar events conditional link

Post by jakovbak »

Your untested code has been tested and it works (also in August). I have tried with both expressions turned on (yours and original template code) and, no wonder, no calendar was produced at all in the front end. Guess there's only 'else' condition we have to figure out how to insert and the problem would be solved.
By "we" I don't count much on myself... ;)
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar events conditional link

Post by velden »

Yeah, but your checking for color != '#ffffff' but you've set textColor.

So change your JS:

Code: Select all

eventClick: function(event, jsEvent, view) {
     if(  event.textColor != '#ffffff') {
          window.location = event.detail_url;
     }
}
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

[SOLVED] Re: CGCalendar events conditional link

Post by jakovbak »

That's it!!! It works like a charm and all I can do now is to say "Thank you Velden, once again you have saved the day!"
Best regards and have great rest of the day, week and year!
Sincerely, your biggest fan,
Jakovbak
;D ;D ;D
Post Reply

Return to “The Lounge”