Design and CSS styles
Version 5.x > Design and CSS styles > Calendar Widget View modes: 
User avatar
Member
Member
ljohnson-melloncg - 2/11/2011 11:16:27 PM
   
Calendar Widget
Greetings!
long time lurker, first time poster. please be gentle.

I have a calendar widget, small one. I'm trying to get it to where if there is an event, it only makes the date number bold and makes it a link to the event page. I'm not currently worried about if there is more than one event in a day. my problem is, a transform only works for the area below/after the date, and the calendar control itself does not have the ability to handle an event day, only day, weekend, current for styling purposes. has anyone tried anything like this? can someone point me in the correct direction?

User avatar
Member
Member
damian-brandcape.co - 2/15/2011 5:14:15 PM
   
RE:Calendar Widget
Hi

Incredibly - I'm doing much the same - (struggling a bit ) when I came across your post. I think I have a solution based on this:

http://devnet.kentico.com/Knowledge-Base/Web-parts---Controls/How-to-display-only-current-month-dates-in-Event-c.aspx

But all I've done in the DayRender event is:

protected void calItems_DayRender(object sender, DayRenderEventArgs e)
{
e.Cell.Text = "<a style='display:block' href='"+CMSContext.CurrentAliasPath+".aspx?date="+ Server.UrlEncode(e.Day.Date.ToString())+"'>" + e.Day.Date.Day + "</a>";

}

and then to get the backgournd color:
(in the setupControl method)

TableItemStyle style = new TableItemStyle();
style.BackColor = Color.FromArgb(232, 232, 232);
style.CssClass = "DayEvents";
calItems.DayWithEventsStyle = style;

Seems to work.

I've hard coded by address that I'm linking to (filterevents for the day) Probably better to do that based on a web part property. (I cloned the normal calendar web part in the viewers folder instead of the actual event calendar control).

User avatar
Member
Member
ljohnson-melloncg - 2/16/2011 11:47:19 AM
   
RE:Calendar Widget
I think you've pointed me in the right direction. thanks!

the link itself does not seem to work, though. I've tried putting the text in, and I've also tried the following:

HyperLink link = new HyperLink();
link.Text = e.Day.Date.Day.ToString();
link.NavigateUrl = CMSContext.CurrentAliasPath + ".aspx?date=" + Server.UrlEncode(e.Day.Date.ToString());
e.Cell.Controls.Add(link);


I've even tried to put test text in there - no joy. it just shows the day number. no errors, it just gets ignored.

User avatar
Member
Member
ljohnson-melloncg - 2/16/2011 11:47:22 AM
   
RE:Calendar Widget
I think you've pointed me in the right direction. thanks!

the link itself does not seem to work, though. I've tried putting the text in, and I've also tried the following:

HyperLink link = new HyperLink();
link.Text = e.Day.Date.Day.ToString();
link.NavigateUrl = CMSContext.CurrentAliasPath + ".aspx?date=" + Server.UrlEncode(e.Day.Date.ToString());
e.Cell.Controls.Add(link);


I've even tried to put test text in there - no joy. it just shows the day number. no errors, it just gets ignored.

User avatar
Member
Member
ljohnson-melloncg - 2/17/2011 2:55:03 PM
   
RE:Calendar Widget
alright. I now have it putting a link into every day. now I just have to have it only put the correct document into only the days with an event. anyone gone through this? it seems like there should be a flag available that says, "this day has an event!" with an associated document. has anyone been though this?

thanks.
Larry

User avatar
Certified Developer 9
Certified Developer 9
petar-kozjak - 2/21/2011 1:41:31 AM
   
RE:Calendar Widget
Hi,

I had this problem last week. Thanks to Kentico great support we got the solution.

Go to: ~\CMSWebParts\Events\EventCalendar.ascx.cs fiind method SetupControl() and add this:
this.calItems.HideDefaultDayNumber = true;

So now everything will be done from transformations. Create transformation for NoEvent and HasEvents in you Document Type cms.events or cms.eventbooking.

NoEvent will have only days:
<%# Eval("__day") %>

HasEvent will have days with links and events, but it will need to check if there is more then one event per days so it doesn't display 2-3 times same date number:
<%# (DisplayIndex == 0) ? ("<a href=\"" + GetDocumentUrl() + "\">" + Eval("__day") + "</a>") : "" %>

Again this was not my solution. It was provided by Kentico support.

That you guys again!

User avatar
Member
Member
nikunj.it007-gmail - 4/4/2012 9:27:08 AM
   
RE:Calendar Widget
hii guys,
I have same issue.i am using eventcalendar.but i have problem that there is no property for eventday.currently i did this way

<div class="<%# (Convert.ToDateTime(Eval("EventDate")).ToString("dd/MM/yyyy")==Convert.ToDateTime(DateTime.Today).ToString("dd/MM/yyyy"))?"": IfCompare(Eval("EventName"), "","EventDay","") %>" >
<a href='<%# HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path).ToString().Replace("CMSPages/PortalTemplate.aspx","NewHome.aspx")+ "?D=" + Convert.ToDateTime(Eval("EventDate")).Day + "&M=" + Convert.ToDateTime(Eval("EventDate")).Month + "&Y=" + Convert.ToDateTime(Eval("EventDate")).Year %>'>
<%# IfCompare(Eval("__order"), 0, "", Eval("__day")) %></a>
</div>
in transforamtion. and finally it generates html like
<td Class="Day">
<div class="EventDay">
1
</div>
</td>
so is there any way to replace td class(DAY) by div class(EventDay) or can i use render event to do this. please give brief idea that in whic user control i have to do.
Thanks,
Nikunj

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 4/6/2012 5:22:06 AM
   
RE:Calendar Widget
Hi,

would you like to hide day number in case there is no event related to this date?

In this case the post above describes how to do it:

~\CMSWebParts\Events\EventCalendar.ascx.cs fiind method SetupControl() and add this:
this.calItems.HideDefaultDayNumber = true;


In version 6.0 you can find property Hide default day number in the Event calendar web part. It also allowed you to define a different transformation for event day and no event date.

Best regards,
Ivana Tomanickova