• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: CGCalendar events conditional link
PostPosted: Thu Dec 07, 2017 8:36 am 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
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:
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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Mon Dec 11, 2017 10:35 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3028
Location: The Netherlands
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Mon Dec 11, 2017 12:34 pm 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Mon Dec 11, 2017 2:01 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3028
Location: The Netherlands
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 7:57 am 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
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...


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 8:29 am 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
Meanwhile, I came across this:

https://forum.cmsmadesimple.org/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!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 9:05 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3028
Location: The Netherlands
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:
eventClick: function(event, jsEvent, view) {
     if(  event.color != '#ffffff') {
          window.location = event.detail_url;
     }
}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 9:51 am 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
It's still in progress on my computer but similar calendar is here:

http://www.bakinidvori.studioides.com/index.php?page=availability

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...


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 10:01 am 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
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... ;)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 10:22 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3028
Location: The Netherlands
Yeah, but your checking for color != '#ffffff' but you've set textColor.

So change your JS:


Code:
eventClick: function(event, jsEvent, view) {
     if(  event.textColor != '#ffffff') {
          window.location = event.detail_url;
     }
}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: [SOLVED] Re: CGCalendar events conditional link
PostPosted: Tue Dec 12, 2017 10:33 am 
Offline
Forum Members
Forum Members

Joined: Thu Dec 13, 2012 2:54 pm
Posts: 198
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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting